SlideShare a Scribd company logo
1 of 48
python3
@andrewsmedina
porquê python3?
        ‣   apresentação, “python3”




globo
 .com
python3 no python2
divisão
        ‣   // em vez de /
        ‣   from __future__ import division




globo
 .com
separe dados binários de string
        ‣   b”” e u””
        ‣   unicode e bytes
        ‣   https://gist.github.com/4128327




globo
 .com
use “iterator-methods” para dicionários
        ‣   iterkeys, iteritems, itervalues




globo
 .com
context managers
        ‣   with
        ‣   https://gist.github.com/4128513




globo
 .com
custom context managers
        ‣   __enter__
        ‣   __exit__
        ‣   https://gist.github.com/4128516




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




globo
 .com
set literals
        ‣   {1,1,1}




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




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




globo
 .com
generators
        ‣   yield
        ‣   https://gist.github.com/4128556




globo
 .com
generator expression
        ‣   (x for x in 'Silly Walk')




globo
 .com
print
        ‣   from __future__ import print_function
        ‣   https://gist.github.com/4128557
        ‣   https://gist.github.com/4128561




globo
 .com
classes abstratas
        ‣   https://gist.github.com/4128566




globo
 .com
multiprocessing
        ‣   https://gist.github.com/4128572




globo
 .com
OrderedDict
        ‣   https://gist.github.com/4128574




globo
 .com
ambiente de desenvolvimento
instalação
        ‣   http://python.org/download/releases/3.3.0/




globo
 .com
virtualenv
        ‣   pyvenv myenv
        ‣   python -m venv myenv




globo
 .com
distribute
        ‣   curl -O http://python-distribute.org/distribute_setup.py
        ‣   python distribute_setup.py




globo
 .com
pip
        ‣   easy_install pip




globo
 .com
o que mudou
range, zip, map, filter
        ‣   retornam iterators
        ‣   cuidado com “x = range(5)”




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




globo
 .com
exceptions
        ‣   except IOError as e:




globo
 .com
class ClassName:
        ‣   new style
        ‣   antes era “class ClassName(object):”




globo
 .com
str/bytes
        ‣   python2 -> str == unicode
        ‣   python2 -> bytes == str
        ‣   antes a conversão era implícita




globo
 .com
str/bytes
        ‣   str (unicode no python2) para representação
        ‣   bytes (str no python2) para transferência




globo
 .com
int
        ‣   long foi renomeado para int




globo
 .com
novidades
annotations
        ‣   adiciona meta dados em uma função
        ‣   https://gist.github.com/4128579




globo
 .com
str.format()
        ‣   nova maneira de formatar strings




globo
 .com
str.format_map()
        ‣   nova maneira de formatar strings




globo
 .com
bytearray
        ‣   mutável




globo
 .com
memoryview
        ‣   https://gist.github.com/4128582




globo
 .com
FileIO
        ‣   substitui métodos do módulo os
        ‣   https://gist.github.com/4128583




globo
 .com
concurrent.futures
        ‣   https://gist.github.com/4128587
        ‣   https://gist.github.com/4128588




globo
 .com
functools.lru_cache
        ‣   memoização
        ‣   https://gist.github.com/4128591




globo
 .com
como portar
apenas python3




globo
 .com
python 2 e 3




globo
 .com
2to3




globo
 .com
3to2
        ‣   pip install 3to2




globo
 .com
six
        ‣   pip install six




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




globo
 .com
obrigado!

More Related Content

What's hot

GIT_GITHUB_2016_06_17
GIT_GITHUB_2016_06_17GIT_GITHUB_2016_06_17
GIT_GITHUB_2016_06_17
siva ram
 
GLX, DRI, and i965
GLX, DRI, and i965GLX, DRI, and i965
GLX, DRI, and i965
Chia-I Wu
 
Rubinius @ RubyAndRails2010
Rubinius @ RubyAndRails2010Rubinius @ RubyAndRails2010
Rubinius @ RubyAndRails2010
Dirkjan Bussink
 
Web 2 .Zero Programming Providers
Web 2 .Zero Programming ProvidersWeb 2 .Zero Programming Providers
Web 2 .Zero Programming Providers
ebooker97
 
CL metaprogramming
CL metaprogrammingCL metaprogramming
CL metaprogramming
dudarev
 

What's hot (20)

Git avançado
Git avançadoGit avançado
Git avançado
 
Make A Shoot ‘Em Up Game with Amethyst Framework
Make A Shoot ‘Em Up Game with Amethyst FrameworkMake A Shoot ‘Em Up Game with Amethyst Framework
Make A Shoot ‘Em Up Game with Amethyst Framework
 
GIT_GITHUB_2016_06_17
GIT_GITHUB_2016_06_17GIT_GITHUB_2016_06_17
GIT_GITHUB_2016_06_17
 
Building a DSL with GraalVM (VoxxedDays Luxembourg)
Building a DSL with GraalVM (VoxxedDays Luxembourg)Building a DSL with GraalVM (VoxxedDays Luxembourg)
Building a DSL with GraalVM (VoxxedDays Luxembourg)
 
GLX, DRI, and i965
GLX, DRI, and i965GLX, DRI, and i965
GLX, DRI, and i965
 
Functional php
Functional phpFunctional php
Functional php
 
Rubinius @ RubyAndRails2010
Rubinius @ RubyAndRails2010Rubinius @ RubyAndRails2010
Rubinius @ RubyAndRails2010
 
C++
C++C++
C++
 
Quicli - From zero to a full CLI application in a few lines of Rust
Quicli - From zero to a full CLI application in a few lines of RustQuicli - From zero to a full CLI application in a few lines of Rust
Quicli - From zero to a full CLI application in a few lines of Rust
 
PyCon KR 2019 sprint - RustPython by example
PyCon KR 2019 sprint  - RustPython by examplePyCon KR 2019 sprint  - RustPython by example
PyCon KR 2019 sprint - RustPython by example
 
Dafunctor
DafunctorDafunctor
Dafunctor
 
我在豆瓣使用Emacs
我在豆瓣使用Emacs我在豆瓣使用Emacs
我在豆瓣使用Emacs
 
Celebrating Guile 2020. Lessons Learned in the Last Lap to Guile 3 (FOSDEM 2020)
Celebrating Guile 2020. Lessons Learned in the Last Lap to Guile 3 (FOSDEM 2020)Celebrating Guile 2020. Lessons Learned in the Last Lap to Guile 3 (FOSDEM 2020)
Celebrating Guile 2020. Lessons Learned in the Last Lap to Guile 3 (FOSDEM 2020)
 
Web 2 .Zero Programming Providers
Web 2 .Zero Programming ProvidersWeb 2 .Zero Programming Providers
Web 2 .Zero Programming Providers
 
File Handling Program
File Handling ProgramFile Handling Program
File Handling Program
 
Building a DSL with GraalVM (CodeOne)
Building a DSL with GraalVM (CodeOne)Building a DSL with GraalVM (CodeOne)
Building a DSL with GraalVM (CodeOne)
 
Modern frontend in react.js
Modern frontend in react.jsModern frontend in react.js
Modern frontend in react.js
 
Inc decsourcefile
Inc decsourcefileInc decsourcefile
Inc decsourcefile
 
CL metaprogramming
CL metaprogrammingCL metaprogramming
CL metaprogramming
 
Full Stack Clojure
Full Stack ClojureFull Stack Clojure
Full Stack Clojure
 

Similar to Python 3 - tutorial

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
Matt Harrison
 
GoLang & GoatCore
GoLang & GoatCore GoLang & GoatCore
GoLang & GoatCore
Sebastian Pożoga
 
2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku
ronnywang_tw
 
Node.js basics
Node.js basicsNode.js basics
Node.js basics
Ben Lin
 

Similar to Python 3 - tutorial (20)

Python 3
Python 3Python 3
Python 3
 
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
 
cgo and Go plugins
cgo and Go pluginscgo and Go plugins
cgo and Go plugins
 
Build Systems with autoconf, automake and libtool [updated]
Build Systems with autoconf, automake and libtool [updated]Build Systems with autoconf, automake and libtool [updated]
Build Systems with autoconf, automake and libtool [updated]
 
Boost.Python: C++ and Python Integration
Boost.Python: C++ and Python IntegrationBoost.Python: C++ and Python Integration
Boost.Python: C++ and Python Integration
 
Improving go-git performance
Improving go-git performanceImproving go-git performance
Improving go-git performance
 
Using Nix and Docker as automated deployment solutions
Using Nix and Docker as automated deployment solutionsUsing Nix and Docker as automated deployment solutions
Using Nix and Docker as automated deployment solutions
 
2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku
 
Groovy for java developers
Groovy for java developersGroovy for java developers
Groovy for java developers
 
Taming AEM deployments
Taming AEM deploymentsTaming AEM deployments
Taming AEM deployments
 
Google V8 engine
Google V8 engineGoogle V8 engine
Google V8 engine
 
Introduction to Griffon
Introduction to GriffonIntroduction to Griffon
Introduction to Griffon
 
Startup Camp - Git, Python, Django session
Startup Camp - Git, Python, Django sessionStartup Camp - Git, Python, Django session
Startup Camp - Git, Python, Django session
 
Node.js basics
Node.js basicsNode.js basics
Node.js basics
 
Php 5.6 From the Inside Out
Php 5.6 From the Inside OutPhp 5.6 From the Inside Out
Php 5.6 From the Inside Out
 
Package a PyApp as a Flatpak Package: An HTTP Server for Example @ PyCon APAC...
Package a PyApp as a Flatpak Package: An HTTP Server for Example @ PyCon APAC...Package a PyApp as a Flatpak Package: An HTTP Server for Example @ PyCon APAC...
Package a PyApp as a Flatpak Package: An HTTP Server for Example @ PyCon APAC...
 
OpenStack How To - PyLadies ATX
OpenStack How To - PyLadies ATXOpenStack How To - PyLadies ATX
OpenStack How To - PyLadies ATX
 
[GSoC 2017] gopy: Updating gopy to support Python3 and PyPy
[GSoC 2017] gopy: Updating gopy to support Python3 and PyPy[GSoC 2017] gopy: Updating gopy to support Python3 and PyPy
[GSoC 2017] gopy: Updating gopy to support Python3 and PyPy
 
How to use git without rage
How to use git without rageHow to use git without rage
How to use git without rage
 

More from Andrews 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 web
Andrews Medina
 
escalando aplicações django
escalando aplicações djangoescalando aplicações django
escalando aplicações django
Andrews Medina
 
Desenvolvimento de Jogos em Python
Desenvolvimento de Jogos em PythonDesenvolvimento de Jogos em Python
Desenvolvimento de Jogos em Python
Andrews Medina
 

More from Andrews Medina (11)

Escalando aplicações web
Escalando aplicações webEscalando aplicações web
Escalando aplicações web
 
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
 
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
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Recently uploaded (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
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
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
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?
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
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...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 

Python 3 - tutorial

Editor's Notes

  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