SlideShare ist ein Scribd-Unternehmen logo
1 von 39
Downloaden Sie, um offline zu lesen
How to train your Python! 
be a pythonista! 
Par Jordi Riera 
La marque de commerce Linux® est utilisée conformément à une sous-licence de LMI, licencié exclusif de Linus Torvalds, propriétaire de la marque au niveau mondial .
Jordi Riera - Odoo Technical Consultant & Python Developer 
7 ans d'expérience en pipeline dont : 
- Pipeline développeur à MPC 
- Pipeline TD à Sony Pictures Imageworks
Vous et python?
1. Introduction à ipython 
2. Pimp my code
ipython
ipython : le shell des vrais et durs! 
voir des feignants... 
Savoir-faire Linux | 6
● Powerful interactive shells (terminal and Qt-based). 
● A browser-based notebook with support for code, text, mathematical expressivons, 
inline plots and other rich media. 
● Support for interactive data visualization and use of GUI toolkits. 
● Flexible, embeddable interpreters to load into your own projects. 
● Easy to use, high performance tools for parallel computing. 
ipython.org 
Savoir-faire Linux | 7
En direct de votre Shell : > ipython 
> pip install ipython
ou du browser : > ipython notebook
Pimp my code
Loopers
for est un foreach 
In [1]: speakers = ['Christian', 'Eric', 'Dave', 'Jordi'] 
In [2]: for i in range(len(speakers)): 
...: print speakers[i] 
In [3]: for speaker in speakers: 
...: print speaker
Index dans une boucle for 
In [1]: speakers = ['Christian', 'Eric', 'Dave', 'Jordi'] 
In [2]: for i in range(len(speakers)): 
...: print i, speakers[i]
Index dans une boucle for 
In [1]: speakers = ['Christian', 'Eric', 'Dave', 'Jordi'] 
In [2]: for i in range(len(speakers)): 
...: print i, speakers[i] 
In [3]: for i, speaker in enumerate(speakers): 
...: print i, speaker
range 
In [1]: for i in [0, 1, 2, 3, 4, 5]: 
...: print i 
In [2]: for i in range(6): 
...: print i
range 
In [1]: for i in [0, 1, 2, 3, 4, 5]: 
...: print i 
In [2]: for i in range(6): 
...: print i 
In [3]: for i in xrange(6): 
...: print i
Compréhension à la portée de tous 
In [1]: a = [] 
In [2]: for i in xrange(10): 
...: if not i % 2: 
...: a.append(i) 
In [3]: a 
Out[3]: [0, 2, 4, 6, 8]
Compréhension à la portée de tous 
In [1]: a = [] 
In [2]: for i in xrange(10): 
...: if not i % 2: 
...: a.append(i) 
In [3]: a 
Out[3]: [0, 2, 4, 6, 8] 
In [4]: a = [i for i in xrange(10) if not i % 2] 
In [5]: a 
Out[5]: [0, 2, 4, 6, 8]
Almost all set 
In [1]: a = range(10000) + range(20000) + range(30000) 
In [2]: b = [] 
In [3]: for i in a: 
...: if not i in b: 
...: b.append(i)
Almost all set 
In [1]: a = range(10000) + range(20000) + range(30000) 
In [2]: b = [] 
In [3]: for i in a: 
...: if not i in b: 
...: b.append(i) 
In [1]: a = range(10000) + range(20000) + range(30000) 
In [2]: b = list(set(a))
The Great Dictionnary
Construire un dict à partir de listes 
In [1]: companies = ['sfl', 'nad'] 
In [2]: people = (['John', 'Jonathan', 'Jordi'], ['Christian']) 
In [3]: d = {} 
In [4]: for i, company in enumerate(companies): 
...: d[company] = people[i] 
...:
Construire un dict à partir de listes 
In [1]: companies = ['sfl', 'nad'] 
In [2]: people = (['John', 'Jonathan', 'Jordi'], ['Christian']) 
In [3]: d = {} 
In [4]: for i, company in enumerate(companies): 
...: d[company] = people[i] 
...: 
In [5]: d = dict(izip(companies, people)) 
Out[5]: {'nad': ['Christian'], 'sfl': ['John', 'Jonathan', 'Jordi']}
Boucles dans un dict 
In [1]: details = { 
'sfl': ['John', 'Jonathan', 'Jordi'], 
'nad': ['Christian'] 
} 
In [2]: for key in details.keys(): 
...: print key
Boucles dans un dict 
In [1]: details = { 
'sfl': ['John', 'Jonathan', 'Jordi'], 
'nad': ['Christian'] 
} 
In [2]: for key in details.keys(): 
...: print key 
In [3]: for key in details: 
...: print key
Boucles dans un dict 
In [1]: details = { 
'sfl': ['John', 'Jonathan', 'Jordi'], 
'nad': ['Christian'] 
} 
In [2]: for key in details.keys(): 
...: print key 
In [3]: for key in details: 
...: print key 
In [4]: for key in details.iterkeys(): 
...: print key
Iteration mais pas tout le temps 
In [1]: for k in details.iterkeys(): 
....: if k == 'sfl': 
....: del details[k] 
RuntimeError: dictionary changed size during iteration
Iteration mais pas tout le temps 
In [1]: for k in details.iterkeys(): 
....: if k == 'sfl': 
....: del details[k] 
RuntimeError: dictionary changed size during iteration 
In [2]: for k in details.keys(): 
....: if k == 'sfl': 
....: del details[k]
Boucles dans un dict 
Autres outils d'itérations dans un dictionnaire: 
.keys() <-> .iterkeys() 
.values() <-> .itervalues() 
.items() <-> .iteritems()
Remplir un dictionnaire 
In [1]: people = (['John', 'sfl'], ['Jonathan', 'sfl'], ['Jordi', 'sfl'], 
['Christian', 'nad']) 
In [2]: d = {} 
In [3]: for p, company in peopls.iteritems(): 
...: if company not in d: 
...: d[company] = [] 
...: d[company].append(p)
Remplir un dictionnaire 
In [1]: people = (['John', 'sfl'], ['Jonathan', 'sfl'], ['Jordi', 'sfl'], 
['Christian', 'nad']) 
In [2]: d = {} 
In [3]: for p, company in people.iteritems(): 
...: if company not in d: 
...: d[company] = [] 
...: d[company].append(p) 
In [4]: for p, company in people.iteritems(): 
....: d.setdefault(company, []).append(p)
Remplir un dictionnaire 
In [5]: from collections import defaultdict 
In [6]: d = defaultdict(list) 
In [7]: for p, company in people.iteritems(): 
....: d[company].append(p)
The Bone Collections
In [1]: {'john': 'sfl', 'jonathan': 'sfl', 'jordi':'sfl' , 'christian':'nad'} 
Out[1]: {'christian': 'nad', 'john': 'sfl', 'jonathan': 'sfl', 'jordi': 'sfl'}
OrderedDict 
In [1]: {'john': 'sfl', 'jonathan': 'sfl', 'jordi':'sfl' , 'christian':'nad'} 
Out[1]: {'christian': 'nad', 'john': 'sfl', 'jonathan': 'sfl', 'jordi': 'sfl'} 
In [2]: d = OrderedDict() 
In [3]: d['John'] = 'sfl' 
In [4]: d['Jonathan'] = 'sfl' 
In [5]: d['Jordi'] = 'sfl' 
In [6]: d['Christian'] = 'nad' 
In [7]: d 
Out[7]: OrderedDict([('John', 'sfl'), ('Jonathan', 'sfl'), ('Jordi', 'sfl'), 
('Christian', 'nad')])
namedtuple 
In [1]: get_points() 
Out[1]: [(65, 28, 45, 255, 255, 87), (255, 255, 87, 65, 28, 45)] 
In [2]: get_points() 
Out[2]: [Coord_color(x=65, y=28, z=45, r=255, g=255, b=87), 
Coord_color(x=255, y=255, z=87, r=65, g=28, b=45)]
namedtuple 
In [1]: from collections import namedtuple 
In [2]: Coord_color = namedtuple('Coord_color', ['x', 'y', 'z', 'r', 'g', 'b']) 
In [3]: [Coord_color(65, 28, 45, 255, 255, 87), Coord_color(255, 255, 87, 65, 
28, 45)] 
Out[3]: [Coord_color(x=65, y=28, z=45, r=255, g=255, b=87), 
Coord_color(x=255, y=255, z=87, r=65, g=28, b=45)] 
Namedtuple est une sous classe de tuple, lui donnant les mêmes 
méthodes qu'un tuple.
1-877-735-4689 
contact@savoirfairelinux.com 
http://www.savoirfairelinux.com
Nous recrutons! 
http://carrieres.savoirfairelinux.com/

Weitere ähnliche Inhalte

Andere mochten auch

SHOWDOWN: Threat Stack vs. Red Hat AuditD
SHOWDOWN: Threat Stack vs. Red Hat AuditDSHOWDOWN: Threat Stack vs. Red Hat AuditD
SHOWDOWN: Threat Stack vs. Red Hat AuditDThreat Stack
 
Protecting confidential files using SE-Linux
Protecting confidential files using SE-LinuxProtecting confidential files using SE-Linux
Protecting confidential files using SE-LinuxGiuseppe Paterno'
 
Open Audit
Open AuditOpen Audit
Open Auditncspa
 
Dealing with Linux Malware
Dealing with Linux MalwareDealing with Linux Malware
Dealing with Linux MalwareMichael Boelen
 
Bringing Infosec Into The Devops Tribe: Q&A With Gene Kim and Pete Cheslock
Bringing Infosec Into The Devops Tribe: Q&A With Gene Kim and Pete CheslockBringing Infosec Into The Devops Tribe: Q&A With Gene Kim and Pete Cheslock
Bringing Infosec Into The Devops Tribe: Q&A With Gene Kim and Pete CheslockThreat Stack
 
Everyone Matters In Infosec 2014
Everyone Matters In Infosec 2014Everyone Matters In Infosec 2014
Everyone Matters In Infosec 2014Micah Hoffman
 
Whitepaper: User Audit Options for Linux and Solaris
Whitepaper: User Audit Options for Linux and SolarisWhitepaper: User Audit Options for Linux and Solaris
Whitepaper: User Audit Options for Linux and SolarisObserveIT
 
MySQL Day Paris 2016 - MySQL Enterprise Edition
MySQL Day Paris 2016 - MySQL Enterprise EditionMySQL Day Paris 2016 - MySQL Enterprise Edition
MySQL Day Paris 2016 - MySQL Enterprise EditionOlivier DASINI
 
2009-08-11 IBM Teach the Teachers (IBM T3), Linux Security Overview
2009-08-11 IBM Teach the Teachers (IBM T3), Linux Security Overview2009-08-11 IBM Teach the Teachers (IBM T3), Linux Security Overview
2009-08-11 IBM Teach the Teachers (IBM T3), Linux Security OverviewShawn Wells
 
Network Security and Analysis with Python
Network Security and Analysis with PythonNetwork Security and Analysis with Python
Network Security and Analysis with Pythonpycontw
 
Linux Security Scanning with Lynis
Linux Security Scanning with LynisLinux Security Scanning with Lynis
Linux Security Scanning with LynisMichael Boelen
 
Handling of compromised Linux systems
Handling of compromised Linux systemsHandling of compromised Linux systems
Handling of compromised Linux systemsMichael Boelen
 
PowerShell for Penetration Testers
PowerShell for Penetration TestersPowerShell for Penetration Testers
PowerShell for Penetration TestersNikhil Mittal
 
Linux Security for Developers
Linux Security for DevelopersLinux Security for Developers
Linux Security for DevelopersMichael Boelen
 
AMSI: How Windows 10 Plans to Stop Script-Based Attacks and How Well It Does It
AMSI: How Windows 10 Plans to Stop Script-Based Attacks and How Well It Does ItAMSI: How Windows 10 Plans to Stop Script-Based Attacks and How Well It Does It
AMSI: How Windows 10 Plans to Stop Script-Based Attacks and How Well It Does ItNikhil Mittal
 
PowerUp - Automating Windows Privilege Escalation
PowerUp - Automating Windows Privilege EscalationPowerUp - Automating Windows Privilege Escalation
PowerUp - Automating Windows Privilege EscalationWill Schroeder
 

Andere mochten auch (20)

SHOWDOWN: Threat Stack vs. Red Hat AuditD
SHOWDOWN: Threat Stack vs. Red Hat AuditDSHOWDOWN: Threat Stack vs. Red Hat AuditD
SHOWDOWN: Threat Stack vs. Red Hat AuditD
 
Audit
AuditAudit
Audit
 
Protecting confidential files using SE-Linux
Protecting confidential files using SE-LinuxProtecting confidential files using SE-Linux
Protecting confidential files using SE-Linux
 
Linux audit framework
Linux audit frameworkLinux audit framework
Linux audit framework
 
Open Audit
Open AuditOpen Audit
Open Audit
 
Dealing with Linux Malware
Dealing with Linux MalwareDealing with Linux Malware
Dealing with Linux Malware
 
Bringing Infosec Into The Devops Tribe: Q&A With Gene Kim and Pete Cheslock
Bringing Infosec Into The Devops Tribe: Q&A With Gene Kim and Pete CheslockBringing Infosec Into The Devops Tribe: Q&A With Gene Kim and Pete Cheslock
Bringing Infosec Into The Devops Tribe: Q&A With Gene Kim and Pete Cheslock
 
Everyone Matters In Infosec 2014
Everyone Matters In Infosec 2014Everyone Matters In Infosec 2014
Everyone Matters In Infosec 2014
 
Whitepaper: User Audit Options for Linux and Solaris
Whitepaper: User Audit Options for Linux and SolarisWhitepaper: User Audit Options for Linux and Solaris
Whitepaper: User Audit Options for Linux and Solaris
 
Python build your security tools.pdf
Python build your security tools.pdfPython build your security tools.pdf
Python build your security tools.pdf
 
MySQL Day Paris 2016 - MySQL Enterprise Edition
MySQL Day Paris 2016 - MySQL Enterprise EditionMySQL Day Paris 2016 - MySQL Enterprise Edition
MySQL Day Paris 2016 - MySQL Enterprise Edition
 
2009-08-11 IBM Teach the Teachers (IBM T3), Linux Security Overview
2009-08-11 IBM Teach the Teachers (IBM T3), Linux Security Overview2009-08-11 IBM Teach the Teachers (IBM T3), Linux Security Overview
2009-08-11 IBM Teach the Teachers (IBM T3), Linux Security Overview
 
Network Security and Analysis with Python
Network Security and Analysis with PythonNetwork Security and Analysis with Python
Network Security and Analysis with Python
 
Linux Security Scanning with Lynis
Linux Security Scanning with LynisLinux Security Scanning with Lynis
Linux Security Scanning with Lynis
 
Handling of compromised Linux systems
Handling of compromised Linux systemsHandling of compromised Linux systems
Handling of compromised Linux systems
 
Linux Hardening
Linux HardeningLinux Hardening
Linux Hardening
 
PowerShell for Penetration Testers
PowerShell for Penetration TestersPowerShell for Penetration Testers
PowerShell for Penetration Testers
 
Linux Security for Developers
Linux Security for DevelopersLinux Security for Developers
Linux Security for Developers
 
AMSI: How Windows 10 Plans to Stop Script-Based Attacks and How Well It Does It
AMSI: How Windows 10 Plans to Stop Script-Based Attacks and How Well It Does ItAMSI: How Windows 10 Plans to Stop Script-Based Attacks and How Well It Does It
AMSI: How Windows 10 Plans to Stop Script-Based Attacks and How Well It Does It
 
PowerUp - Automating Windows Privilege Escalation
PowerUp - Automating Windows Privilege EscalationPowerUp - Automating Windows Privilege Escalation
PowerUp - Automating Windows Privilege Escalation
 

Ähnlich wie How To Train Your Python

A Few of My Favorite (Python) Things
A Few of My Favorite (Python) ThingsA Few of My Favorite (Python) Things
A Few of My Favorite (Python) ThingsMichael Pirnat
 
intro_to_python_20150825
intro_to_python_20150825intro_to_python_20150825
intro_to_python_20150825Shung-Hsi Yu
 
Python于Web 2.0网站的应用 - QCon Beijing 2010
Python于Web 2.0网站的应用 - QCon Beijing 2010Python于Web 2.0网站的应用 - QCon Beijing 2010
Python于Web 2.0网站的应用 - QCon Beijing 2010Qiangning Hong
 
2 UNIT CH3 Dictionaries v1.ppt
2 UNIT CH3 Dictionaries v1.ppt2 UNIT CH3 Dictionaries v1.ppt
2 UNIT CH3 Dictionaries v1.ppttocidfh
 
Basics of Python programming (part 2)
Basics of Python programming (part 2)Basics of Python programming (part 2)
Basics of Python programming (part 2)Pedro Rodrigues
 
CS 151 dictionary objects
CS 151 dictionary objectsCS 151 dictionary objects
CS 151 dictionary objectsRudy Martinez
 
Becoming a Pythonist
Becoming a PythonistBecoming a Pythonist
Becoming a PythonistRaji Engg
 
Python for data science by www.dmdiploma.com
Python for data science by www.dmdiploma.comPython for data science by www.dmdiploma.com
Python for data science by www.dmdiploma.comShwetaAggarwal56
 
R for Pythonistas (PyData NYC 2017)
R for Pythonistas (PyData NYC 2017)R for Pythonistas (PyData NYC 2017)
R for Pythonistas (PyData NYC 2017)Christopher Roach
 

Ähnlich wie How To Train Your Python (20)

ch1_slides.pdf
ch1_slides.pdfch1_slides.pdf
ch1_slides.pdf
 
Python Puzzlers
Python PuzzlersPython Puzzlers
Python Puzzlers
 
Python slide
Python slidePython slide
Python slide
 
A Few of My Favorite (Python) Things
A Few of My Favorite (Python) ThingsA Few of My Favorite (Python) Things
A Few of My Favorite (Python) Things
 
Dictionary in python
Dictionary in pythonDictionary in python
Dictionary in python
 
intro_to_python_20150825
intro_to_python_20150825intro_to_python_20150825
intro_to_python_20150825
 
Python于Web 2.0网站的应用 - QCon Beijing 2010
Python于Web 2.0网站的应用 - QCon Beijing 2010Python于Web 2.0网站的应用 - QCon Beijing 2010
Python于Web 2.0网站的应用 - QCon Beijing 2010
 
Python 101 1
Python 101   1Python 101   1
Python 101 1
 
2 UNIT CH3 Dictionaries v1.ppt
2 UNIT CH3 Dictionaries v1.ppt2 UNIT CH3 Dictionaries v1.ppt
2 UNIT CH3 Dictionaries v1.ppt
 
Basics of Python programming (part 2)
Basics of Python programming (part 2)Basics of Python programming (part 2)
Basics of Python programming (part 2)
 
Python for Dummies
Python for DummiesPython for Dummies
Python for Dummies
 
CS 151 dictionary objects
CS 151 dictionary objectsCS 151 dictionary objects
CS 151 dictionary objects
 
Intro to Python
Intro to PythonIntro to Python
Intro to Python
 
PMED Undergraduate Workshop - R Tutorial for PMED Undegraduate Workshop - Xi...
PMED Undergraduate Workshop - R Tutorial for PMED Undegraduate Workshop  - Xi...PMED Undergraduate Workshop - R Tutorial for PMED Undegraduate Workshop  - Xi...
PMED Undergraduate Workshop - R Tutorial for PMED Undegraduate Workshop - Xi...
 
Practical File Grade 12.pdf
Practical File Grade 12.pdfPractical File Grade 12.pdf
Practical File Grade 12.pdf
 
Becoming a Pythonist
Becoming a PythonistBecoming a Pythonist
Becoming a Pythonist
 
Python for data science by www.dmdiploma.com
Python for data science by www.dmdiploma.comPython for data science by www.dmdiploma.com
Python for data science by www.dmdiploma.com
 
R for Pythonistas (PyData NYC 2017)
R for Pythonistas (PyData NYC 2017)R for Pythonistas (PyData NYC 2017)
R for Pythonistas (PyData NYC 2017)
 
Python dictionaries
Python dictionariesPython dictionaries
Python dictionaries
 
Procesamiento del lenguaje natural con python
Procesamiento del lenguaje natural con pythonProcesamiento del lenguaje natural con python
Procesamiento del lenguaje natural con python
 

Kürzlich hochgeladen

DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 

Kürzlich hochgeladen (20)

DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 

How To Train Your Python

  • 1. How to train your Python! be a pythonista! Par Jordi Riera La marque de commerce Linux® est utilisée conformément à une sous-licence de LMI, licencié exclusif de Linus Torvalds, propriétaire de la marque au niveau mondial .
  • 2. Jordi Riera - Odoo Technical Consultant & Python Developer 7 ans d'expérience en pipeline dont : - Pipeline développeur à MPC - Pipeline TD à Sony Pictures Imageworks
  • 4. 1. Introduction à ipython 2. Pimp my code
  • 6. ipython : le shell des vrais et durs! voir des feignants... Savoir-faire Linux | 6
  • 7. ● Powerful interactive shells (terminal and Qt-based). ● A browser-based notebook with support for code, text, mathematical expressivons, inline plots and other rich media. ● Support for interactive data visualization and use of GUI toolkits. ● Flexible, embeddable interpreters to load into your own projects. ● Easy to use, high performance tools for parallel computing. ipython.org Savoir-faire Linux | 7
  • 8. En direct de votre Shell : > ipython > pip install ipython
  • 9. ou du browser : > ipython notebook
  • 12. for est un foreach In [1]: speakers = ['Christian', 'Eric', 'Dave', 'Jordi'] In [2]: for i in range(len(speakers)): ...: print speakers[i] In [3]: for speaker in speakers: ...: print speaker
  • 13. Index dans une boucle for In [1]: speakers = ['Christian', 'Eric', 'Dave', 'Jordi'] In [2]: for i in range(len(speakers)): ...: print i, speakers[i]
  • 14. Index dans une boucle for In [1]: speakers = ['Christian', 'Eric', 'Dave', 'Jordi'] In [2]: for i in range(len(speakers)): ...: print i, speakers[i] In [3]: for i, speaker in enumerate(speakers): ...: print i, speaker
  • 15. range In [1]: for i in [0, 1, 2, 3, 4, 5]: ...: print i In [2]: for i in range(6): ...: print i
  • 16. range In [1]: for i in [0, 1, 2, 3, 4, 5]: ...: print i In [2]: for i in range(6): ...: print i In [3]: for i in xrange(6): ...: print i
  • 17. Compréhension à la portée de tous In [1]: a = [] In [2]: for i in xrange(10): ...: if not i % 2: ...: a.append(i) In [3]: a Out[3]: [0, 2, 4, 6, 8]
  • 18. Compréhension à la portée de tous In [1]: a = [] In [2]: for i in xrange(10): ...: if not i % 2: ...: a.append(i) In [3]: a Out[3]: [0, 2, 4, 6, 8] In [4]: a = [i for i in xrange(10) if not i % 2] In [5]: a Out[5]: [0, 2, 4, 6, 8]
  • 19. Almost all set In [1]: a = range(10000) + range(20000) + range(30000) In [2]: b = [] In [3]: for i in a: ...: if not i in b: ...: b.append(i)
  • 20. Almost all set In [1]: a = range(10000) + range(20000) + range(30000) In [2]: b = [] In [3]: for i in a: ...: if not i in b: ...: b.append(i) In [1]: a = range(10000) + range(20000) + range(30000) In [2]: b = list(set(a))
  • 22. Construire un dict à partir de listes In [1]: companies = ['sfl', 'nad'] In [2]: people = (['John', 'Jonathan', 'Jordi'], ['Christian']) In [3]: d = {} In [4]: for i, company in enumerate(companies): ...: d[company] = people[i] ...:
  • 23. Construire un dict à partir de listes In [1]: companies = ['sfl', 'nad'] In [2]: people = (['John', 'Jonathan', 'Jordi'], ['Christian']) In [3]: d = {} In [4]: for i, company in enumerate(companies): ...: d[company] = people[i] ...: In [5]: d = dict(izip(companies, people)) Out[5]: {'nad': ['Christian'], 'sfl': ['John', 'Jonathan', 'Jordi']}
  • 24. Boucles dans un dict In [1]: details = { 'sfl': ['John', 'Jonathan', 'Jordi'], 'nad': ['Christian'] } In [2]: for key in details.keys(): ...: print key
  • 25. Boucles dans un dict In [1]: details = { 'sfl': ['John', 'Jonathan', 'Jordi'], 'nad': ['Christian'] } In [2]: for key in details.keys(): ...: print key In [3]: for key in details: ...: print key
  • 26. Boucles dans un dict In [1]: details = { 'sfl': ['John', 'Jonathan', 'Jordi'], 'nad': ['Christian'] } In [2]: for key in details.keys(): ...: print key In [3]: for key in details: ...: print key In [4]: for key in details.iterkeys(): ...: print key
  • 27. Iteration mais pas tout le temps In [1]: for k in details.iterkeys(): ....: if k == 'sfl': ....: del details[k] RuntimeError: dictionary changed size during iteration
  • 28. Iteration mais pas tout le temps In [1]: for k in details.iterkeys(): ....: if k == 'sfl': ....: del details[k] RuntimeError: dictionary changed size during iteration In [2]: for k in details.keys(): ....: if k == 'sfl': ....: del details[k]
  • 29. Boucles dans un dict Autres outils d'itérations dans un dictionnaire: .keys() <-> .iterkeys() .values() <-> .itervalues() .items() <-> .iteritems()
  • 30. Remplir un dictionnaire In [1]: people = (['John', 'sfl'], ['Jonathan', 'sfl'], ['Jordi', 'sfl'], ['Christian', 'nad']) In [2]: d = {} In [3]: for p, company in peopls.iteritems(): ...: if company not in d: ...: d[company] = [] ...: d[company].append(p)
  • 31. Remplir un dictionnaire In [1]: people = (['John', 'sfl'], ['Jonathan', 'sfl'], ['Jordi', 'sfl'], ['Christian', 'nad']) In [2]: d = {} In [3]: for p, company in people.iteritems(): ...: if company not in d: ...: d[company] = [] ...: d[company].append(p) In [4]: for p, company in people.iteritems(): ....: d.setdefault(company, []).append(p)
  • 32. Remplir un dictionnaire In [5]: from collections import defaultdict In [6]: d = defaultdict(list) In [7]: for p, company in people.iteritems(): ....: d[company].append(p)
  • 34. In [1]: {'john': 'sfl', 'jonathan': 'sfl', 'jordi':'sfl' , 'christian':'nad'} Out[1]: {'christian': 'nad', 'john': 'sfl', 'jonathan': 'sfl', 'jordi': 'sfl'}
  • 35. OrderedDict In [1]: {'john': 'sfl', 'jonathan': 'sfl', 'jordi':'sfl' , 'christian':'nad'} Out[1]: {'christian': 'nad', 'john': 'sfl', 'jonathan': 'sfl', 'jordi': 'sfl'} In [2]: d = OrderedDict() In [3]: d['John'] = 'sfl' In [4]: d['Jonathan'] = 'sfl' In [5]: d['Jordi'] = 'sfl' In [6]: d['Christian'] = 'nad' In [7]: d Out[7]: OrderedDict([('John', 'sfl'), ('Jonathan', 'sfl'), ('Jordi', 'sfl'), ('Christian', 'nad')])
  • 36. namedtuple In [1]: get_points() Out[1]: [(65, 28, 45, 255, 255, 87), (255, 255, 87, 65, 28, 45)] In [2]: get_points() Out[2]: [Coord_color(x=65, y=28, z=45, r=255, g=255, b=87), Coord_color(x=255, y=255, z=87, r=65, g=28, b=45)]
  • 37. namedtuple In [1]: from collections import namedtuple In [2]: Coord_color = namedtuple('Coord_color', ['x', 'y', 'z', 'r', 'g', 'b']) In [3]: [Coord_color(65, 28, 45, 255, 255, 87), Coord_color(255, 255, 87, 65, 28, 45)] Out[3]: [Coord_color(x=65, y=28, z=45, r=255, g=255, b=87), Coord_color(x=255, y=255, z=87, r=65, g=28, b=45)] Namedtuple est une sous classe de tuple, lui donnant les mêmes méthodes qu'un tuple.