SlideShare a Scribd company logo
10 Reasons to Adopt Python 3
About Me
Pierre Fersing – pierref@bleemeo.com
CTO & co-founder @Bleemeo
Python & Django dev for 10 years
Monitoring as a Service solution
API in Django + User Interface in ReactJS
① Comparison in Python
>>> ["user1", 20] < ["user2", 10]
True
>>> ["user1", 20] < ["user1", 30]
True
① Comparison in Python
Py2 : False !
Py3 : TypeError: unorderable types: tuple() < list()
>>> ("user1", 20) < ["user2", 99]
>>> max("one", 2)
"one"
② Iterators, Iterators Everywhere
Consume about 1,5 GB of memory with Python
2 !
range vs xrange, keys vs iterkeys, values vs
itervalues, items vs iteritems
zip, map, filter
>>> for _ in range(50000000):
... the_answer = 42
③ Keywords Only Arguments
>>> def sortwords(
... words, reverse, case_sensitive):
>>> sortwords(
... ["one", "two", "three"],
... reverse=True, case_sensitive=False)
③ Keywords Only Arguments
>>> def sortwords(
... words, reverse, case_sensitive):
>>> sortwords(
... ["one", "two", "three"], True, False)
>>> def sortwords(
... words, case_sensitive, reverse):
>>> def sortwords(
... words, *, case_sensitive, reverse):
③ Keyword Arguments
>>> sortwords(
... "one", "two", "three",
... case_sensitive=False
... )
>>> def sortwords(*words, **kwargs):
... case_sensitive = 
... kwargs.pop("case_sensitive")
③ Keyword Arguments
>>> sortwords(
... "one", "two", "three",
... case_sensitive=False
... )
>>> def sortwords(
... *words, case_sensitive=True):
④ Improved Except Syntax
>>> try:
... 0 / 0
... except OSError, ZeroDivisionError:
... print("Error")
④ Improved Except Syntax
>>> try:
... 0 / 0
... except (OSError, ZeroDivisionError) as err:
... print("Error")
⑤ Chained Exceptions
>>> try:
... connection = do_connect()
... # do stuff
... finally:
... connection.close()
Traceback (most recent call last):
File "code.py", line 5, in <module>
connection.close()
NameError: name 'connection' is not defined
⑤ Chained Exceptions
Traceback (most recent call last):
File "plop.py", line 2, in <module>
connection = do_connect()
ConnectionRefusedError: [Errno 111]
Connection refused
During handling of the above exception,
another exception occurred:
Traceback (most recent call last):
File "plop.py", line 5, in <module>
connection.close()
NameError: name 'connection' is not defined
⑥ Reworked OS/IO Exception
>>> try:
... fd = open("/etc/shadow")
... except IOError:
... print("Error")
>>> try:
... os.stat("/etc/shadow")
... except OSError:
... print("Error")
⑥ Reworked OS/IO Exception
>>> try:
... fd = open("/etc/shadow")
... except IOError as err:
... if err.errno in (EACCES, EPERM):
... print("Error")
... else:
... raise
⑥ Reworked OS/IO Exception
>>> try:
... fd = open("/etc/shadow")
... except PermissionError:
... print("Error")
⑦ Reworked Stdlib Names
Which module ? urllib, urllib2, urlparse ?
– Parsing an url : urlparse
– Quoting an URL : urllib
– Do a requests : urllib2
No more cPickle, cProfile, cStringIO
⑧ Stdlib Additions
>>> etc = pathlib.Path("/etc")
... file = etc / "passwd"
... file.read_text()
>>> @functools.lru_cache(max_size=32)
... def expansive_function(params):
⑧ Stdlib Additions
>>> subprocess.run(
... ["ls", "-l"], timeout=10)
>>> datetime.now().timestamp()
>>> secrets.token_urlsafe()
⑧ Stdlib Additions
Lots more :
– lzma
– enum
– ipaddress
– faulthandler
– statistics
– ...
⑨ asyncio and async/await
>>> reader,writer = await asyncio.open_connection(
... "www.python.org", 80)
... writer.write(b'GET / […]')
... async for line in reader:
... # do something with the line
⑩ Bonus
>>> 1 / 2
0.5
>>> for x in iterable:
... yield x
>>> yield from iterable
⑩ Bonus
Tab-completion in interpreter
>>> class Children(Parent):
... def method(self):
... super().method()
⑩ Bonus
>>> round(1.5)
2
>>> round(2.5)
2
Question ?

More Related Content

Viewers also liked

Temas de pensamiento administrativo 2 corte
Temas de pensamiento administrativo 2 corteTemas de pensamiento administrativo 2 corte
Temas de pensamiento administrativo 2 corte
wilder yepes
 
Evaluating unconciousness in icu
Evaluating unconciousness in icuEvaluating unconciousness in icu
Evaluating unconciousness in icu
nss115
 
La evolución de las comunicaciones
La evolución de las comunicacionesLa evolución de las comunicaciones
La evolución de las comunicaciones
Rita Veron
 
Gaining &amp; maintaining access to stigmatized samples (revised final)-6-1-15
Gaining &amp; maintaining  access to stigmatized samples (revised final)-6-1-15Gaining &amp; maintaining  access to stigmatized samples (revised final)-6-1-15
Gaining &amp; maintaining access to stigmatized samples (revised final)-6-1-15
dcprojectconnect
 
Semiótica
SemióticaSemiótica
Semiótica
Luz Millan
 
Contaminación aire y agua
Contaminación aire y agua Contaminación aire y agua
Contaminación aire y agua
Luz Millan
 
Monitoring in the Cloud Era
Monitoring in the Cloud EraMonitoring in the Cloud Era
Monitoring in the Cloud Era
Bleemeo
 
Votre infrastructure est élastique, et votre monitoring ?
Votre infrastructure est élastique, et votre monitoring ?Votre infrastructure est élastique, et votre monitoring ?
Votre infrastructure est élastique, et votre monitoring ?
Bleemeo
 
Descubrir la brecha digital en México
Descubrir la brecha digital en MéxicoDescubrir la brecha digital en México
Descubrir la brecha digital en México
Edith Suarez
 
Alimentación balanceada
Alimentación balanceada Alimentación balanceada
Alimentación balanceada
jhonatan gonzalez carora
 
Dalmo taxa selic
Dalmo taxa selicDalmo taxa selic
Dalmo taxa selic
Dalmo Júnior
 
Pensamiento administrativo (1)
Pensamiento administrativo (1)Pensamiento administrativo (1)
Pensamiento administrativo (1)
wilder yepes
 
Contaminación
ContaminaciónContaminación
Contaminación
Luz Millan
 
CSP068-6 BRO ENG A4 CS Solutions (1)
CSP068-6 BRO ENG A4 CS Solutions (1)CSP068-6 BRO ENG A4 CS Solutions (1)
CSP068-6 BRO ENG A4 CS Solutions (1)Carlos G. Silva
 
Jhonatan alcaldia
Jhonatan alcaldiaJhonatan alcaldia
Jhonatan alcaldia
jhonatan gonzalez carora
 
Temas de administracion 3 corte
Temas de administracion 3 corteTemas de administracion 3 corte
Temas de administracion 3 corte
wilder yepes
 
Presentation on PD- Ravi Bhatt
Presentation on PD- Ravi BhattPresentation on PD- Ravi Bhatt
Presentation on PD- Ravi BhattRavi Bhatt
 
Strategic Purchasing Supply Initiatives
Strategic Purchasing Supply InitiativesStrategic Purchasing Supply Initiatives
Strategic Purchasing Supply Initiatives
ignasuhe
 
Presentación de Milagros Talí
Presentación de Milagros TalíPresentación de Milagros Talí
Presentación de Milagros Talí
Milagros Talí
 

Viewers also liked (20)

Temas de pensamiento administrativo 2 corte
Temas de pensamiento administrativo 2 corteTemas de pensamiento administrativo 2 corte
Temas de pensamiento administrativo 2 corte
 
Evaluating unconciousness in icu
Evaluating unconciousness in icuEvaluating unconciousness in icu
Evaluating unconciousness in icu
 
La evolución de las comunicaciones
La evolución de las comunicacionesLa evolución de las comunicaciones
La evolución de las comunicaciones
 
MY PORT 30.11.16
MY PORT 30.11.16MY PORT 30.11.16
MY PORT 30.11.16
 
Gaining &amp; maintaining access to stigmatized samples (revised final)-6-1-15
Gaining &amp; maintaining  access to stigmatized samples (revised final)-6-1-15Gaining &amp; maintaining  access to stigmatized samples (revised final)-6-1-15
Gaining &amp; maintaining access to stigmatized samples (revised final)-6-1-15
 
Semiótica
SemióticaSemiótica
Semiótica
 
Contaminación aire y agua
Contaminación aire y agua Contaminación aire y agua
Contaminación aire y agua
 
Monitoring in the Cloud Era
Monitoring in the Cloud EraMonitoring in the Cloud Era
Monitoring in the Cloud Era
 
Votre infrastructure est élastique, et votre monitoring ?
Votre infrastructure est élastique, et votre monitoring ?Votre infrastructure est élastique, et votre monitoring ?
Votre infrastructure est élastique, et votre monitoring ?
 
Descubrir la brecha digital en México
Descubrir la brecha digital en MéxicoDescubrir la brecha digital en México
Descubrir la brecha digital en México
 
Alimentación balanceada
Alimentación balanceada Alimentación balanceada
Alimentación balanceada
 
Dalmo taxa selic
Dalmo taxa selicDalmo taxa selic
Dalmo taxa selic
 
Pensamiento administrativo (1)
Pensamiento administrativo (1)Pensamiento administrativo (1)
Pensamiento administrativo (1)
 
Contaminación
ContaminaciónContaminación
Contaminación
 
CSP068-6 BRO ENG A4 CS Solutions (1)
CSP068-6 BRO ENG A4 CS Solutions (1)CSP068-6 BRO ENG A4 CS Solutions (1)
CSP068-6 BRO ENG A4 CS Solutions (1)
 
Jhonatan alcaldia
Jhonatan alcaldiaJhonatan alcaldia
Jhonatan alcaldia
 
Temas de administracion 3 corte
Temas de administracion 3 corteTemas de administracion 3 corte
Temas de administracion 3 corte
 
Presentation on PD- Ravi Bhatt
Presentation on PD- Ravi BhattPresentation on PD- Ravi Bhatt
Presentation on PD- Ravi Bhatt
 
Strategic Purchasing Supply Initiatives
Strategic Purchasing Supply InitiativesStrategic Purchasing Supply Initiatives
Strategic Purchasing Supply Initiatives
 
Presentación de Milagros Talí
Presentación de Milagros TalíPresentación de Milagros Talí
Presentación de Milagros Talí
 

Similar to 10 reasons to adopt Python 3

Python Exception handling using Try-Except-Finally
Python Exception handling using Try-Except-FinallyPython Exception handling using Try-Except-Finally
Python Exception handling using Try-Except-Finally
Vinod Srivastava
 
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
DRVaibhavmeshram1
 
Zope component architechture
Zope component architechtureZope component architechture
Zope component architechture
Anatoly Bubenkov
 
Error and exception in python
Error and exception in pythonError and exception in python
Error and exception in python
junnubabu
 
Python fundamentals - basic | WeiYuan
Python fundamentals - basic | WeiYuanPython fundamentals - basic | WeiYuan
Python fundamentals - basic | WeiYuan
Wei-Yuan Chang
 
Porting to Python 3
Porting to Python 3Porting to Python 3
Porting to Python 3
Lennart Regebro
 
Javantura v2 - Replication with MongoDB - what could go wrong... - Philipp Krenn
Javantura v2 - Replication with MongoDB - what could go wrong... - Philipp KrennJavantura v2 - Replication with MongoDB - what could go wrong... - Philipp Krenn
Javantura v2 - Replication with MongoDB - what could go wrong... - Philipp Krenn
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
Python 3
Python 3Python 3
Python 3
Andrews Medina
 
Debugging of (C)Python applications
Debugging of (C)Python applicationsDebugging of (C)Python applications
Debugging of (C)Python applications
Roman Podoliaka
 
Server discovery and monitoring with MongoDB
Server discovery and monitoring with MongoDBServer discovery and monitoring with MongoDB
Server discovery and monitoring with MongoDB
Joe Drumgoole
 
Introduction to clojure
Introduction to clojureIntroduction to clojure
Introduction to clojure
Abbas Raza
 
Pemrograman Python untuk Pemula
Pemrograman Python untuk PemulaPemrograman Python untuk Pemula
Pemrograman Python untuk Pemula
Oon Arfiandwi
 
Exception Handling In Python | Exceptions In Python | Python Programming Tuto...
Exception Handling In Python | Exceptions In Python | Python Programming Tuto...Exception Handling In Python | Exceptions In Python | Python Programming Tuto...
Exception Handling In Python | Exceptions In Python | Python Programming Tuto...
Edureka!
 
Erlang Developments: The Good, The Bad and The Ugly
Erlang Developments: The Good, The Bad and The UglyErlang Developments: The Good, The Bad and The Ugly
Erlang Developments: The Good, The Bad and The Ugly
enriquepazperez
 
Tuning Java Servers
Tuning Java Servers Tuning Java Servers
Tuning Java Servers
Srinath Perera
 
The Ring programming language version 1.5.2 book - Part 26 of 181
The Ring programming language version 1.5.2 book - Part 26 of 181The Ring programming language version 1.5.2 book - Part 26 of 181
The Ring programming language version 1.5.2 book - Part 26 of 181
Mahmoud Samir Fayed
 
Hierarchical free monads and software design in fp
Hierarchical free monads and software design in fpHierarchical free monads and software design in fp
Hierarchical free monads and software design in fp
Alexander Granin
 
The Ring programming language version 1.5.3 book - Part 25 of 184
The Ring programming language version 1.5.3 book - Part 25 of 184The Ring programming language version 1.5.3 book - Part 25 of 184
The Ring programming language version 1.5.3 book - Part 25 of 184
Mahmoud Samir Fayed
 
PythonBrasil[8] - CPython for dummies
PythonBrasil[8] - CPython for dummiesPythonBrasil[8] - CPython for dummies
PythonBrasil[8] - CPython for dummies
Tatiana Al-Chueyr
 
Python Network Programming – Course Applications Guide
Python Network Programming – Course Applications GuidePython Network Programming – Course Applications Guide
Python Network Programming – Course Applications Guide
Mihai Catalin Teodosiu
 

Similar to 10 reasons to adopt Python 3 (20)

Python Exception handling using Try-Except-Finally
Python Exception handling using Try-Except-FinallyPython Exception handling using Try-Except-Finally
Python Exception handling using Try-Except-Finally
 
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
 
Zope component architechture
Zope component architechtureZope component architechture
Zope component architechture
 
Error and exception in python
Error and exception in pythonError and exception in python
Error and exception in python
 
Python fundamentals - basic | WeiYuan
Python fundamentals - basic | WeiYuanPython fundamentals - basic | WeiYuan
Python fundamentals - basic | WeiYuan
 
Porting to Python 3
Porting to Python 3Porting to Python 3
Porting to Python 3
 
Javantura v2 - Replication with MongoDB - what could go wrong... - Philipp Krenn
Javantura v2 - Replication with MongoDB - what could go wrong... - Philipp KrennJavantura v2 - Replication with MongoDB - what could go wrong... - Philipp Krenn
Javantura v2 - Replication with MongoDB - what could go wrong... - Philipp Krenn
 
Python 3
Python 3Python 3
Python 3
 
Debugging of (C)Python applications
Debugging of (C)Python applicationsDebugging of (C)Python applications
Debugging of (C)Python applications
 
Server discovery and monitoring with MongoDB
Server discovery and monitoring with MongoDBServer discovery and monitoring with MongoDB
Server discovery and monitoring with MongoDB
 
Introduction to clojure
Introduction to clojureIntroduction to clojure
Introduction to clojure
 
Pemrograman Python untuk Pemula
Pemrograman Python untuk PemulaPemrograman Python untuk Pemula
Pemrograman Python untuk Pemula
 
Exception Handling In Python | Exceptions In Python | Python Programming Tuto...
Exception Handling In Python | Exceptions In Python | Python Programming Tuto...Exception Handling In Python | Exceptions In Python | Python Programming Tuto...
Exception Handling In Python | Exceptions In Python | Python Programming Tuto...
 
Erlang Developments: The Good, The Bad and The Ugly
Erlang Developments: The Good, The Bad and The UglyErlang Developments: The Good, The Bad and The Ugly
Erlang Developments: The Good, The Bad and The Ugly
 
Tuning Java Servers
Tuning Java Servers Tuning Java Servers
Tuning Java Servers
 
The Ring programming language version 1.5.2 book - Part 26 of 181
The Ring programming language version 1.5.2 book - Part 26 of 181The Ring programming language version 1.5.2 book - Part 26 of 181
The Ring programming language version 1.5.2 book - Part 26 of 181
 
Hierarchical free monads and software design in fp
Hierarchical free monads and software design in fpHierarchical free monads and software design in fp
Hierarchical free monads and software design in fp
 
The Ring programming language version 1.5.3 book - Part 25 of 184
The Ring programming language version 1.5.3 book - Part 25 of 184The Ring programming language version 1.5.3 book - Part 25 of 184
The Ring programming language version 1.5.3 book - Part 25 of 184
 
PythonBrasil[8] - CPython for dummies
PythonBrasil[8] - CPython for dummiesPythonBrasil[8] - CPython for dummies
PythonBrasil[8] - CPython for dummies
 
Python Network Programming – Course Applications Guide
Python Network Programming – Course Applications GuidePython Network Programming – Course Applications Guide
Python Network Programming – Course Applications Guide
 

Recently uploaded

GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 

Recently uploaded (20)

GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 

10 reasons to adopt Python 3

  • 1. 10 Reasons to Adopt Python 3
  • 2. About Me Pierre Fersing – pierref@bleemeo.com CTO & co-founder @Bleemeo Python & Django dev for 10 years
  • 3. Monitoring as a Service solution API in Django + User Interface in ReactJS
  • 4. ① Comparison in Python >>> ["user1", 20] < ["user2", 10] True >>> ["user1", 20] < ["user1", 30] True
  • 5. ① Comparison in Python Py2 : False ! Py3 : TypeError: unorderable types: tuple() < list() >>> ("user1", 20) < ["user2", 99] >>> max("one", 2) "one"
  • 6. ② Iterators, Iterators Everywhere Consume about 1,5 GB of memory with Python 2 ! range vs xrange, keys vs iterkeys, values vs itervalues, items vs iteritems zip, map, filter >>> for _ in range(50000000): ... the_answer = 42
  • 7. ③ Keywords Only Arguments >>> def sortwords( ... words, reverse, case_sensitive): >>> sortwords( ... ["one", "two", "three"], ... reverse=True, case_sensitive=False)
  • 8. ③ Keywords Only Arguments >>> def sortwords( ... words, reverse, case_sensitive): >>> sortwords( ... ["one", "two", "three"], True, False) >>> def sortwords( ... words, case_sensitive, reverse): >>> def sortwords( ... words, *, case_sensitive, reverse):
  • 9. ③ Keyword Arguments >>> sortwords( ... "one", "two", "three", ... case_sensitive=False ... ) >>> def sortwords(*words, **kwargs): ... case_sensitive = ... kwargs.pop("case_sensitive")
  • 10. ③ Keyword Arguments >>> sortwords( ... "one", "two", "three", ... case_sensitive=False ... ) >>> def sortwords( ... *words, case_sensitive=True):
  • 11. ④ Improved Except Syntax >>> try: ... 0 / 0 ... except OSError, ZeroDivisionError: ... print("Error")
  • 12. ④ Improved Except Syntax >>> try: ... 0 / 0 ... except (OSError, ZeroDivisionError) as err: ... print("Error")
  • 13. ⑤ Chained Exceptions >>> try: ... connection = do_connect() ... # do stuff ... finally: ... connection.close() Traceback (most recent call last): File "code.py", line 5, in <module> connection.close() NameError: name 'connection' is not defined
  • 14. ⑤ Chained Exceptions Traceback (most recent call last): File "plop.py", line 2, in <module> connection = do_connect() ConnectionRefusedError: [Errno 111] Connection refused During handling of the above exception, another exception occurred: Traceback (most recent call last): File "plop.py", line 5, in <module> connection.close() NameError: name 'connection' is not defined
  • 15. ⑥ Reworked OS/IO Exception >>> try: ... fd = open("/etc/shadow") ... except IOError: ... print("Error") >>> try: ... os.stat("/etc/shadow") ... except OSError: ... print("Error")
  • 16. ⑥ Reworked OS/IO Exception >>> try: ... fd = open("/etc/shadow") ... except IOError as err: ... if err.errno in (EACCES, EPERM): ... print("Error") ... else: ... raise
  • 17. ⑥ Reworked OS/IO Exception >>> try: ... fd = open("/etc/shadow") ... except PermissionError: ... print("Error")
  • 18. ⑦ Reworked Stdlib Names Which module ? urllib, urllib2, urlparse ? – Parsing an url : urlparse – Quoting an URL : urllib – Do a requests : urllib2 No more cPickle, cProfile, cStringIO
  • 19. ⑧ Stdlib Additions >>> etc = pathlib.Path("/etc") ... file = etc / "passwd" ... file.read_text() >>> @functools.lru_cache(max_size=32) ... def expansive_function(params):
  • 20. ⑧ Stdlib Additions >>> subprocess.run( ... ["ls", "-l"], timeout=10) >>> datetime.now().timestamp() >>> secrets.token_urlsafe()
  • 21. ⑧ Stdlib Additions Lots more : – lzma – enum – ipaddress – faulthandler – statistics – ...
  • 22. ⑨ asyncio and async/await >>> reader,writer = await asyncio.open_connection( ... "www.python.org", 80) ... writer.write(b'GET / […]') ... async for line in reader: ... # do something with the line
  • 23. ⑩ Bonus >>> 1 / 2 0.5 >>> for x in iterable: ... yield x >>> yield from iterable
  • 24. ⑩ Bonus Tab-completion in interpreter >>> class Children(Parent): ... def method(self): ... super().method()