SlideShare una empresa de Scribd logo
1 de 71
python3
@andrewsmedina
‣   o que os outros pensam...




globo
 .com
‣   o que eu penso...




globo
 .com
‣   o que minha mãe pensa...




globo
 .com
‣   como realmente é!




globo
 .com
python 2
‣   pep8              ‣   generators
        ‣   zen of python     ‣   iterators
        ‣   decorators        ‣   comprehension
        ‣   descriptors       ‣   abstract
        ‣   metaclass         ‣   magic methods
        ‣   context manager
        ‣   subproccess
        ‣   multiproccess

globo
 .com
mas...
‣   unicode
        ‣   classes new x old style
        ‣   // vs /
        ‣   print vs print()
        ‣   int vs long
        ‣   urllib, urllib2, urlparse
        ‣   xmlrpclib, DocXMLRPCServer, SimpleXMLRPCServer



globo
 .com
:(
python3
        ‣   pep8
        ‣   zen of python
        ‣   generators
        ‣   iterators
        ‣   objetos




globo
 .com
python3.0
           2008..




globo
 .com
python3.0
        ‣   pip, distribute não funcionava no python3
        ‣   2to3 não foi suficiente




globo
 .com
python3.3
        ‣   pip, distribute
        ‣   venv nativo
        ‣   2to3, 3to2, six
        ‣   várias features já funcionam no python2.7




globo
 .com
python3 no python2
divisão (python2)
         >>> 4 / 2
         2
         >>> 3 / 2
         1



globo
 .com
divisão (python3)
         >>> 3 / 2
         1.5




globo
 .com
divisão (python2)
         from __future__ import division
         >>> 3 / 2
         1.5




globo
 .com
divisão (python2)
         from __future__ import division
         >>> 3 // 2
         1




globo
 .com
string.format()
        “{0} - {1}”.format(“andrews”, 19)
        “{name} - {idade}”.format(name=”andrews”, idade=19)



globo
 .com
comprehension
        {x for x in [1,2,3,3]}




globo
 .com
comprehension
        {key.upper(): value for key, value in d.items()}




globo
 .com
generators


globo
 .com
classes abstratas


globo
 .com
multiprocessing


globo
 .com
bytes e strings
        bytes para transferência
        string para representação



globo
 .com
bytes e strings
        bytes (python3) == str (python2)
        string (python3 == bytes (python2)



globo
 .com
bytes e strings (python2)
        u"andrews " + b"medina"
        u”andrews medina”



globo
 .com
bytes e strings (python3)
        >>> u"andrews " + b"medina"
        Traceback (most recent call last):
         File "<stdin>", line 1, in <module>
        TypeError: Can't convert 'bytes' object to str implicitly


globo
 .com
strings para bytes
        u"andrews ".encode(“utf-8”) + b"medina"




globo
 .com
bytes para strings
        u"andrews " + b"medina".decode(“utf-8”)




globo
 .com
print
        objeto
        novos parâmetros (sep, end, file, flush)



globo
 .com
print (python2)
        >>> help(print)
         File "<stdin>", line 1
           help(print)
                  ^
        SyntaxError: invalid syntax


globo
 .com
print (python3)
        >>> help(print)



globo
 .com
print (python2)
        >>> from __future__ import print_function
        >>> help(print)


globo
 .com
print (python2)
        >>> print(", ".join(["banana", "batata"]))
        banana, batata


globo
 .com
print (python3)
        >>> alimentos = ["banana", "batata"]
        >>> print(*alimentos, sep=", ")
        banana, batata


globo
 .com
print (python3)
        from StringIO import StringIO
        out = StringIO()
        >>> print("ble", file=out)
        >>> out.getvalue()
        'blen'


globo
 .com
range, zip, map, filter
        retornam iterators




globo
 .com
range, zip, map, filter
        lista = list(range(10))




globo
 .com
range, zip, map, filter
        for item in range(10):
           print item




globo
 .com
expections
        except IOError as e:




globo
 .com
class Class:
        new style por padrão




globo
 .com
int
        int = long




globo
 .com
novidades
annotations
        adiciona meta dados em uma função




globo
 .com
annotations
        def hello(name: str, age: int) -> int:
           print(name, age)




globo
 .com
annotations
        >>> hello.__annotations__
        {'return': <class 'int'>, 'name': <class 'str'>, 'age': <class 'int'>}




globo
 .com
annotations
        >>> hello("ble", "ble")
        ble ble




globo
 .com
io
        io.FileIO
        io.StringIO
        io.BufferIO



globo
 .com
concurrent.future
        paralelismo




globo
 .com
concurrent.future
        interface Executor




globo
 .com
concurrent.future
        from concurrent.futures import ThreadPoolExecutor

        with ThreadPoolExecutor(max_workers=1) as executor:
           future = executor.submit(pow, 323, 1235)
           print(future.result())

globo
 .com
concurrent.future
        from concurrent.futures import ProcessPoolExecutor

        with ProcessPoolExecutor(max_workers=4) as executor:
           future = executor.submit(pow, 323, 1235)
           print(future.result())

globo
 .com
functools.lru_cache
        memoização nativa




globo
 .com
functools.lru_cache
        from functools import lru_cache

        @lru_cache(maxsize=None)
        def fib(n):
           if n < 2:
               return n
           return fib(n-1) + fib(n-2)


globo
 .com
venv (virtualenv)


globo
 .com
unittest(2)


globo
 .com
unittest.mock


globo
 .com
pep 420
        Implicit Namespace Packages




globo
 .com
como portar
apenas python3


globo
 .com
branches diferentes
        manter dois projetos :(




globo
 .com
2to3
        convertor automágico




globo
 .com
2to3
        print “ble” -> print(ble)
        except Exception, e -> except Exception as e




globo
 .com
2to3
        2to3=true #distribute




globo
 .com
3to2


globo
 .com
mesma base de código
        tratamento de excessões




globo
 .com
six
        :)




globo
 .com
leitura
        ‣   http://python3porting.com/
        ‣   http://docs.python.org/3/
        ‣   http://getpython3.com/diveintopython3/




globo
 .com
perguntas?

Más contenido relacionado

La actualidad más candente

Allison Kaptur: Bytes in the Machine: Inside the CPython interpreter, PyGotha...
Allison Kaptur: Bytes in the Machine: Inside the CPython interpreter, PyGotha...Allison Kaptur: Bytes in the Machine: Inside the CPython interpreter, PyGotha...
Allison Kaptur: Bytes in the Machine: Inside the CPython interpreter, PyGotha...akaptur
 
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 184Mahmoud Samir Fayed
 
An Intro to Python in 30 minutes
An Intro to Python in 30 minutesAn Intro to Python in 30 minutes
An Intro to Python in 30 minutesSumit Raj
 
Hacking Go Compiler Internals / GoCon 2014 Autumn
Hacking Go Compiler Internals / GoCon 2014 AutumnHacking Go Compiler Internals / GoCon 2014 Autumn
Hacking Go Compiler Internals / GoCon 2014 AutumnMoriyoshi Koizumi
 
Coding in GO - GDG SL - NSBM
Coding in GO - GDG SL - NSBMCoding in GO - GDG SL - NSBM
Coding in GO - GDG SL - NSBMRaveen Perera
 
Euro python2011 High Performance Python
Euro python2011 High Performance PythonEuro python2011 High Performance Python
Euro python2011 High Performance PythonIan Ozsvald
 
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!..."A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...akaptur
 
OpenGurukul : Language : Python
OpenGurukul : Language : PythonOpenGurukul : Language : Python
OpenGurukul : Language : PythonOpen Gurukul
 
Functional Pe(a)rls version 2
Functional Pe(a)rls version 2Functional Pe(a)rls version 2
Functional Pe(a)rls version 2osfameron
 
C++の話(本当にあった怖い話)
C++の話(本当にあった怖い話)C++の話(本当にあった怖い話)
C++の話(本当にあった怖い話)Yuki Tamura
 
ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015Michiel Borkent
 
Go ahead, make my day
Go ahead, make my dayGo ahead, make my day
Go ahead, make my dayTor Ivry
 
Snakes for Camels
Snakes for CamelsSnakes for Camels
Snakes for Camelsmiquelruizm
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript IntroductionHans Höchtl
 
Dts x dicoding #2 memulai pemrograman kotlin
Dts x dicoding #2 memulai pemrograman kotlinDts x dicoding #2 memulai pemrograman kotlin
Dts x dicoding #2 memulai pemrograman kotlinAhmad Arif Faizin
 
OpenGurukul : Language : PHP
OpenGurukul : Language : PHPOpenGurukul : Language : PHP
OpenGurukul : Language : PHPOpen Gurukul
 
Beauty and Power of Go
Beauty and Power of GoBeauty and Power of Go
Beauty and Power of GoFrank Müller
 
ClojureScript for the web
ClojureScript for the webClojureScript for the web
ClojureScript for the webMichiel Borkent
 

La actualidad más candente (20)

Allison Kaptur: Bytes in the Machine: Inside the CPython interpreter, PyGotha...
Allison Kaptur: Bytes in the Machine: Inside the CPython interpreter, PyGotha...Allison Kaptur: Bytes in the Machine: Inside the CPython interpreter, PyGotha...
Allison Kaptur: Bytes in the Machine: Inside the CPython interpreter, PyGotha...
 
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
 
An Intro to Python in 30 minutes
An Intro to Python in 30 minutesAn Intro to Python in 30 minutes
An Intro to Python in 30 minutes
 
Golang勉強会
Golang勉強会Golang勉強会
Golang勉強会
 
Hacking Go Compiler Internals / GoCon 2014 Autumn
Hacking Go Compiler Internals / GoCon 2014 AutumnHacking Go Compiler Internals / GoCon 2014 Autumn
Hacking Go Compiler Internals / GoCon 2014 Autumn
 
Coding in GO - GDG SL - NSBM
Coding in GO - GDG SL - NSBMCoding in GO - GDG SL - NSBM
Coding in GO - GDG SL - NSBM
 
Euro python2011 High Performance Python
Euro python2011 High Performance PythonEuro python2011 High Performance Python
Euro python2011 High Performance Python
 
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!..."A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
 
OpenGurukul : Language : Python
OpenGurukul : Language : PythonOpenGurukul : Language : Python
OpenGurukul : Language : Python
 
Functional Pe(a)rls version 2
Functional Pe(a)rls version 2Functional Pe(a)rls version 2
Functional Pe(a)rls version 2
 
C++の話(本当にあった怖い話)
C++の話(本当にあった怖い話)C++の話(本当にあった怖い話)
C++の話(本当にあった怖い話)
 
ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015
 
Go ahead, make my day
Go ahead, make my dayGo ahead, make my day
Go ahead, make my day
 
Full Stack Clojure
Full Stack ClojureFull Stack Clojure
Full Stack Clojure
 
Snakes for Camels
Snakes for CamelsSnakes for Camels
Snakes for Camels
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
Dts x dicoding #2 memulai pemrograman kotlin
Dts x dicoding #2 memulai pemrograman kotlinDts x dicoding #2 memulai pemrograman kotlin
Dts x dicoding #2 memulai pemrograman kotlin
 
OpenGurukul : Language : PHP
OpenGurukul : Language : PHPOpenGurukul : Language : PHP
OpenGurukul : Language : PHP
 
Beauty and Power of Go
Beauty and Power of GoBeauty and Power of Go
Beauty and Power of Go
 
ClojureScript for the web
ClojureScript for the webClojureScript for the web
ClojureScript for the web
 

Destacado

JSON Schema: Valide e navegue entre suas APIS
JSON Schema: Valide e navegue entre suas APISJSON Schema: Valide e navegue entre suas APIS
JSON Schema: Valide e navegue entre suas APISWilson Júnior
 
Design de código: princípios e práticas para ter um código sustentável
Design de código: princípios e práticas para ter um código sustentávelDesign de código: princípios e práticas para ter um código sustentável
Design de código: princípios e práticas para ter um código sustentávelAndrews Medina
 
CEJS 2016 - Please learn that shit
CEJS 2016 - Please learn that shitCEJS 2016 - Please learn that shit
CEJS 2016 - Please learn that shitEmerson Macedo
 
Escalando aplicações web
Escalando aplicações webEscalando aplicações web
Escalando aplicações webAndrews Medina
 
256 Shades of R, G and B
256 Shades of R, G and B256 Shades of R, G and B
256 Shades of R, G and BAlmir Filho
 

Destacado (6)

JSON Schema: Valide e navegue entre suas APIS
JSON Schema: Valide e navegue entre suas APISJSON Schema: Valide e navegue entre suas APIS
JSON Schema: Valide e navegue entre suas APIS
 
Design de código: princípios e práticas para ter um código sustentável
Design de código: princípios e práticas para ter um código sustentávelDesign de código: princípios e práticas para ter um código sustentável
Design de código: princípios e práticas para ter um código sustentável
 
CEJS 2016 - Please learn that shit
CEJS 2016 - Please learn that shitCEJS 2016 - Please learn that shit
CEJS 2016 - Please learn that shit
 
Escalando aplicações web
Escalando aplicações webEscalando aplicações web
Escalando aplicações web
 
256 Shades of R, G and B
256 Shades of R, G and B256 Shades of R, G and B
256 Shades of R, G and B
 
React Native na globo.com
React Native na globo.comReact Native na globo.com
React Native na globo.com
 

Similar a Python 3

What's new in Python 3.11
What's new in Python 3.11What's new in Python 3.11
What's new in Python 3.11Henry Schreiner
 
Python-GTK
Python-GTKPython-GTK
Python-GTKYuren Ju
 
Python 3000
Python 3000Python 3000
Python 3000Bob Chao
 
Boost.Python: C++ and Python Integration
Boost.Python: C++ and Python IntegrationBoost.Python: C++ and Python Integration
Boost.Python: C++ and Python IntegrationGlobalLogic Ukraine
 
Learn Python 3 for absolute beginners
Learn Python 3 for absolute beginnersLearn Python 3 for absolute beginners
Learn Python 3 for absolute beginnersKingsleyAmankwa
 
Python in 30 minutes!
Python in 30 minutes!Python in 30 minutes!
Python in 30 minutes!Fariz Darari
 
Class 1: Welcome to programming
Class 1: Welcome to programmingClass 1: Welcome to programming
Class 1: Welcome to programmingMarc Gouw
 
Python GTK (Hacking Camp)
Python GTK (Hacking Camp)Python GTK (Hacking Camp)
Python GTK (Hacking Camp)Yuren Ju
 
PyCon 2013 : Scripting to PyPi to GitHub and More
PyCon 2013 : Scripting to PyPi to GitHub and MorePyCon 2013 : Scripting to PyPi to GitHub and More
PyCon 2013 : Scripting to PyPi to GitHub and MoreMatt Harrison
 
Bytes in the Machine: Inside the CPython interpreter
Bytes in the Machine: Inside the CPython interpreterBytes in the Machine: Inside the CPython interpreter
Bytes in the Machine: Inside the CPython interpreterakaptur
 
PythonBrasil[8] - CPython for dummies
PythonBrasil[8] - CPython for dummiesPythonBrasil[8] - CPython for dummies
PythonBrasil[8] - CPython for dummiesTatiana Al-Chueyr
 
EuroPython 2016 : A Deep Dive into the Pymongo Driver
EuroPython 2016 : A Deep Dive into the Pymongo DriverEuroPython 2016 : A Deep Dive into the Pymongo Driver
EuroPython 2016 : A Deep Dive into the Pymongo DriverJoe Drumgoole
 
Functional Programming inside OOP? It’s possible with Python
Functional Programming inside OOP? It’s possible with PythonFunctional Programming inside OOP? It’s possible with Python
Functional Programming inside OOP? It’s possible with PythonCarlos V.
 
Pemrograman Python untuk Pemula
Pemrograman Python untuk PemulaPemrograman Python untuk Pemula
Pemrograman Python untuk PemulaOon Arfiandwi
 
8799.pdfOr else the work is fine only. Lot to learn buddy.... Improve your ba...
8799.pdfOr else the work is fine only. Lot to learn buddy.... Improve your ba...8799.pdfOr else the work is fine only. Lot to learn buddy.... Improve your ba...
8799.pdfOr else the work is fine only. Lot to learn buddy.... Improve your ba...Yashpatel821746
 
Or else the work is fine only. Lot to learn buddy.... Improve your basics in ...
Or else the work is fine only. Lot to learn buddy.... Improve your basics in ...Or else the work is fine only. Lot to learn buddy.... Improve your basics in ...
Or else the work is fine only. Lot to learn buddy.... Improve your basics in ...Yashpatel821746
 

Similar a Python 3 (20)

Python 3 - tutorial
Python 3 - tutorialPython 3 - tutorial
Python 3 - tutorial
 
Porting to Python 3
Porting to Python 3Porting to Python 3
Porting to Python 3
 
Porting to Python 3
Porting to Python 3Porting to Python 3
Porting to Python 3
 
What's new in Python 3.11
What's new in Python 3.11What's new in Python 3.11
What's new in Python 3.11
 
Python-GTK
Python-GTKPython-GTK
Python-GTK
 
Python 3000
Python 3000Python 3000
Python 3000
 
Boost.Python: C++ and Python Integration
Boost.Python: C++ and Python IntegrationBoost.Python: C++ and Python Integration
Boost.Python: C++ and Python Integration
 
Learn Python 3 for absolute beginners
Learn Python 3 for absolute beginnersLearn Python 3 for absolute beginners
Learn Python 3 for absolute beginners
 
Python in 30 minutes!
Python in 30 minutes!Python in 30 minutes!
Python in 30 minutes!
 
Class 1: Welcome to programming
Class 1: Welcome to programmingClass 1: Welcome to programming
Class 1: Welcome to programming
 
Python GTK (Hacking Camp)
Python GTK (Hacking Camp)Python GTK (Hacking Camp)
Python GTK (Hacking Camp)
 
PyCon 2013 : Scripting to PyPi to GitHub and More
PyCon 2013 : Scripting to PyPi to GitHub and MorePyCon 2013 : Scripting to PyPi to GitHub and More
PyCon 2013 : Scripting to PyPi to GitHub and More
 
GoLang & GoatCore
GoLang & GoatCore GoLang & GoatCore
GoLang & GoatCore
 
Bytes in the Machine: Inside the CPython interpreter
Bytes in the Machine: Inside the CPython interpreterBytes in the Machine: Inside the CPython interpreter
Bytes in the Machine: Inside the CPython interpreter
 
PythonBrasil[8] - CPython for dummies
PythonBrasil[8] - CPython for dummiesPythonBrasil[8] - CPython for dummies
PythonBrasil[8] - CPython for dummies
 
EuroPython 2016 : A Deep Dive into the Pymongo Driver
EuroPython 2016 : A Deep Dive into the Pymongo DriverEuroPython 2016 : A Deep Dive into the Pymongo Driver
EuroPython 2016 : A Deep Dive into the Pymongo Driver
 
Functional Programming inside OOP? It’s possible with Python
Functional Programming inside OOP? It’s possible with PythonFunctional Programming inside OOP? It’s possible with Python
Functional Programming inside OOP? It’s possible with Python
 
Pemrograman Python untuk Pemula
Pemrograman Python untuk PemulaPemrograman Python untuk Pemula
Pemrograman Python untuk Pemula
 
8799.pdfOr else the work is fine only. Lot to learn buddy.... Improve your ba...
8799.pdfOr else the work is fine only. Lot to learn buddy.... Improve your ba...8799.pdfOr else the work is fine only. Lot to learn buddy.... Improve your ba...
8799.pdfOr else the work is fine only. Lot to learn buddy.... Improve your ba...
 
Or else the work is fine only. Lot to learn buddy.... Improve your basics in ...
Or else the work is fine only. Lot to learn buddy.... Improve your basics in ...Or else the work is fine only. Lot to learn buddy.... Improve your basics in ...
Or else the work is fine only. Lot to learn buddy.... Improve your basics in ...
 

Más de Andrews Medina

testando interfaces web
testando interfaces webtestando interfaces web
testando interfaces webAndrews Medina
 
desenvolvendo jogos para android
desenvolvendo jogos para androiddesenvolvendo jogos para android
desenvolvendo jogos para androidAndrews Medina
 
técnica de desenvolvimento de jogos para web
técnica de desenvolvimento de jogos para webtécnica de desenvolvimento de jogos para web
técnica de desenvolvimento de jogos para webAndrews Medina
 
realtime - passado, presente e futuro
realtime - passado, presente e futurorealtime - passado, presente e futuro
realtime - passado, presente e futuroAndrews Medina
 
Haskell para pythonistas
Haskell para pythonistasHaskell para pythonistas
Haskell para pythonistasAndrews Medina
 
animações e jogos além do canvas
animações e jogos além do canvasanimações e jogos além do canvas
animações e jogos além do canvasAndrews Medina
 
escalando aplicações django
escalando aplicações djangoescalando aplicações django
escalando aplicações djangoAndrews Medina
 
Desenvolvimento de Jogos em Python
Desenvolvimento de Jogos em PythonDesenvolvimento de Jogos em Python
Desenvolvimento de Jogos em PythonAndrews Medina
 

Más de Andrews Medina (9)

testando interfaces web
testando interfaces webtestando interfaces web
testando interfaces web
 
desenvolvendo jogos para android
desenvolvendo jogos para androiddesenvolvendo jogos para android
desenvolvendo jogos para android
 
técnica de desenvolvimento de jogos para web
técnica de desenvolvimento de jogos para webtécnica de desenvolvimento de jogos para web
técnica de desenvolvimento de jogos para web
 
realtime - passado, presente e futuro
realtime - passado, presente e futurorealtime - passado, presente e futuro
realtime - passado, presente e futuro
 
Haskell para pythonistas
Haskell para pythonistasHaskell para pythonistas
Haskell para pythonistas
 
animações e jogos além do canvas
animações e jogos além do canvasanimações e jogos além do canvas
animações e jogos além do canvas
 
escalando aplicações django
escalando aplicações djangoescalando aplicações django
escalando aplicações django
 
Desenvolvimento de Jogos em Python
Desenvolvimento de Jogos em PythonDesenvolvimento de Jogos em Python
Desenvolvimento de Jogos em Python
 
Django Show
Django ShowDjango Show
Django Show
 

Último

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 

Último (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 

Python 3

  • 2. o que os outros pensam... globo .com
  • 3. o que eu penso... globo .com
  • 4. o que minha mãe pensa... globo .com
  • 5. como realmente é! globo .com
  • 7. pep8 ‣ generators ‣ zen of python ‣ iterators ‣ decorators ‣ comprehension ‣ descriptors ‣ abstract ‣ metaclass ‣ magic methods ‣ context manager ‣ subproccess ‣ multiproccess globo .com
  • 9. unicode ‣ classes new x old style ‣ // vs / ‣ print vs print() ‣ int vs long ‣ urllib, urllib2, urlparse ‣ xmlrpclib, DocXMLRPCServer, SimpleXMLRPCServer globo .com
  • 10. :(
  • 11. python3 ‣ pep8 ‣ zen of python ‣ generators ‣ iterators ‣ objetos globo .com
  • 12. python3.0 2008.. globo .com
  • 13. python3.0 ‣ pip, distribute não funcionava no python3 ‣ 2to3 não foi suficiente globo .com
  • 14. python3.3 ‣ pip, distribute ‣ venv nativo ‣ 2to3, 3to2, six ‣ várias features já funcionam no python2.7 globo .com
  • 16. divisão (python2) >>> 4 / 2 2 >>> 3 / 2 1 globo .com
  • 17. divisão (python3) >>> 3 / 2 1.5 globo .com
  • 18. divisão (python2) from __future__ import division >>> 3 / 2 1.5 globo .com
  • 19. divisão (python2) from __future__ import division >>> 3 // 2 1 globo .com
  • 20. string.format() “{0} - {1}”.format(“andrews”, 19) “{name} - {idade}”.format(name=”andrews”, idade=19) globo .com
  • 21. comprehension {x for x in [1,2,3,3]} globo .com
  • 22. comprehension {key.upper(): value for key, value in d.items()} globo .com
  • 26. bytes e strings bytes para transferência string para representação globo .com
  • 27. bytes e strings bytes (python3) == str (python2) string (python3 == bytes (python2) globo .com
  • 28. bytes e strings (python2) u"andrews " + b"medina" u”andrews medina” globo .com
  • 29. bytes e strings (python3) >>> u"andrews " + b"medina" Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: Can't convert 'bytes' object to str implicitly globo .com
  • 30. strings para bytes u"andrews ".encode(“utf-8”) + b"medina" globo .com
  • 31. bytes para strings u"andrews " + b"medina".decode(“utf-8”) globo .com
  • 32. print objeto novos parâmetros (sep, end, file, flush) globo .com
  • 33. print (python2) >>> help(print) File "<stdin>", line 1 help(print) ^ SyntaxError: invalid syntax globo .com
  • 34. print (python3) >>> help(print) globo .com
  • 35. print (python2) >>> from __future__ import print_function >>> help(print) globo .com
  • 36. print (python2) >>> print(", ".join(["banana", "batata"])) banana, batata globo .com
  • 37. print (python3) >>> alimentos = ["banana", "batata"] >>> print(*alimentos, sep=", ") banana, batata globo .com
  • 38. print (python3) from StringIO import StringIO out = StringIO() >>> print("ble", file=out) >>> out.getvalue() 'blen' globo .com
  • 39. range, zip, map, filter retornam iterators globo .com
  • 40. range, zip, map, filter lista = list(range(10)) globo .com
  • 41. range, zip, map, filter for item in range(10): print item globo .com
  • 42. expections except IOError as e: globo .com
  • 43. class Class: new style por padrão globo .com
  • 44. int int = long globo .com
  • 46. annotations adiciona meta dados em uma função globo .com
  • 47. annotations def hello(name: str, age: int) -> int: print(name, age) globo .com
  • 48. annotations >>> hello.__annotations__ {'return': <class 'int'>, 'name': <class 'str'>, 'age': <class 'int'>} globo .com
  • 49. annotations >>> hello("ble", "ble") ble ble globo .com
  • 50. io io.FileIO io.StringIO io.BufferIO globo .com
  • 51. concurrent.future paralelismo globo .com
  • 52. concurrent.future interface Executor globo .com
  • 53. concurrent.future from concurrent.futures import ThreadPoolExecutor with ThreadPoolExecutor(max_workers=1) as executor: future = executor.submit(pow, 323, 1235) print(future.result()) globo .com
  • 54. concurrent.future from concurrent.futures import ProcessPoolExecutor with ProcessPoolExecutor(max_workers=4) as executor: future = executor.submit(pow, 323, 1235) print(future.result()) globo .com
  • 55. functools.lru_cache memoização nativa globo .com
  • 56. functools.lru_cache from functools import lru_cache @lru_cache(maxsize=None) def fib(n): if n < 2: return n return fib(n-1) + fib(n-2) globo .com
  • 60. pep 420 Implicit Namespace Packages globo .com
  • 63. branches diferentes manter dois projetos :( globo .com
  • 64. 2to3 convertor automágico globo .com
  • 65. 2to3 print “ble” -> print(ble) except Exception, e -> except Exception as e globo .com
  • 66. 2to3 2to3=true #distribute globo .com
  • 68. mesma base de código tratamento de excessões globo .com
  • 69. six :) globo .com
  • 70. leitura ‣ http://python3porting.com/ ‣ http://docs.python.org/3/ ‣ http://getpython3.com/diveintopython3/ globo .com

Notas del editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n