Python 3 - tutorial

  • 1,686 views
Uploaded on

Tutorial sobre Python 3. Onde abordo: …

Tutorial sobre Python 3. Onde abordo:

- como programar python 3 no python 2.
- novidades
- mudanças
- ambiente de desenvolvimento
- como portar

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,686
On Slideshare
0
From Embeds
0
Number of Embeds
6

Actions

Shares
Downloads
36
Comments
0
Likes
3

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Transcript

  • 1. python3@andrewsmedina
  • 2. porquê python3? ‣ apresentação, “python3”globo .com
  • 3. python3 no python2
  • 4. divisão ‣ // em vez de / ‣ from __future__ import divisionglobo .com
  • 5. separe dados binários de string ‣ b”” e u”” ‣ unicode e bytes ‣ https://gist.github.com/4128327globo .com
  • 6. use “iterator-methods” para dicionários ‣ iterkeys, iteritems, itervaluesglobo .com
  • 7. context managers ‣ with ‣ https://gist.github.com/4128513globo .com
  • 8. custom context managers ‣ __enter__ ‣ __exit__ ‣ https://gist.github.com/4128516globo .com
  • 9. str.format() ‣ “{0} - {1}”.format(“andrews”, 19) ‣ “{name} - {idade}”.format(name=”andrews”, idade=19)globo .com
  • 10. set literals ‣ {1,1,1}globo .com
  • 11. set comprehension ‣ {x for x in [1,2,3,3]}globo .com
  • 12. dict comprehension ‣ {key.upper(): value for key, value in d.items()}globo .com
  • 13. generators ‣ yield ‣ https://gist.github.com/4128556globo .com
  • 14. generator expression ‣ (x for x in Silly Walk)globo .com
  • 15. print ‣ from __future__ import print_function ‣ https://gist.github.com/4128557 ‣ https://gist.github.com/4128561globo .com
  • 16. classes abstratas ‣ https://gist.github.com/4128566globo .com
  • 17. multiprocessing ‣ https://gist.github.com/4128572globo .com
  • 18. OrderedDict ‣ https://gist.github.com/4128574globo .com
  • 19. ambiente de desenvolvimento
  • 20. instalação ‣ http://python.org/download/releases/3.3.0/globo .com
  • 21. virtualenv ‣ pyvenv myenv ‣ python -m venv myenvglobo .com
  • 22. distribute ‣ curl -O http://python-distribute.org/distribute_setup.py ‣ python distribute_setup.pyglobo .com
  • 23. pip ‣ easy_install pipglobo .com
  • 24. o que mudou
  • 25. range, zip, map, filter ‣ retornam iterators ‣ cuidado com “x = range(5)”globo .com
  • 26. print ‣ objeto ‣ novos parâmetros (sep, end, file, flush)globo .com
  • 27. exceptions ‣ except IOError as e:globo .com
  • 28. class ClassName: ‣ new style ‣ antes era “class ClassName(object):”globo .com
  • 29. str/bytes ‣ python2 -> str == unicode ‣ python2 -> bytes == str ‣ antes a conversão era implícitaglobo .com
  • 30. str/bytes ‣ str (unicode no python2) para representação ‣ bytes (str no python2) para transferênciaglobo .com
  • 31. int ‣ long foi renomeado para intglobo .com
  • 32. novidades
  • 33. annotations ‣ adiciona meta dados em uma função ‣ https://gist.github.com/4128579globo .com
  • 34. str.format() ‣ nova maneira de formatar stringsglobo .com
  • 35. str.format_map() ‣ nova maneira de formatar stringsglobo .com
  • 36. bytearray ‣ mutávelglobo .com
  • 37. memoryview ‣ https://gist.github.com/4128582globo .com
  • 38. FileIO ‣ substitui métodos do módulo os ‣ https://gist.github.com/4128583globo .com
  • 39. concurrent.futures ‣ https://gist.github.com/4128587 ‣ https://gist.github.com/4128588globo .com
  • 40. functools.lru_cache ‣ memoização ‣ https://gist.github.com/4128591globo .com
  • 41. como portar
  • 42. apenas python3globo .com
  • 43. python 2 e 3globo .com
  • 44. 2to3globo .com
  • 45. 3to2 ‣ pip install 3to2globo .com
  • 46. six ‣ pip install sixglobo .com
  • 47. leitura ‣ http://python3porting.com/ ‣ http://docs.python.org/3/ ‣ http://getpython3.com/diveintopython3/globo .com
  • 48. obrigado!