Your SlideShare is downloading. ×
PYTHON: From programmer to tamer
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

PYTHON: From programmer to tamer

696
views

Published on

Knuth’s sentence "It was nice to learn Python; a nice afternoon" describes very well how easy it is to get engaged and fall in love with our favourite snake. …

Knuth’s sentence "It was nice to learn Python; a nice afternoon" describes very well how easy it is to get engaged and fall in love with our favourite snake.

But if you are a professional programmer and use and abuse Python for paying your bills, there is a chance that your beloved pet will go out of control and bite you!

To save you some scars, I want to share with you 10 topical steps of my evolution from a Python programmer into a Python tamer.

Published in: Technology

0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
696
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
15
Comments
0
Likes
4
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

Transcript

  • 1. PYTHON: From programmer to tamer Alessandro Pisa - 2013/07/03 - EuroPython 2013
  • 2. Software Integrator alessandro.pisa@redturtle.it http://blog.redturtle.it @ale_pisa Alessandro Pisa
  • 3. HOW I MET PYTHON
  • 4. It was nice to play football
  • 5. But rain happens!
  • 6. Gimme more football!
  • 7. c64
  • 8. Something went wrong with Santa...
  • 9. MSX2
  • 10. Let the children play (otherwise bad things happen!)
  • 11. Blue screen of Death... ...all the time!
  • 12. Ready to become a Nerd
  • 13. HARDWARE FAILURES
  • 14. Let's GIVE Software another chance True story :(
  • 15. A lucky afternoon!
  • 16. Ready to gooooo!
  • 17. OR NOT?
  • 18. Question time
  • 19. It's A HARD LIFE
  • 20. Only the strongest will survive
  • 21. RTFM!But...
  • 22. Documentation is searchable and browsable http://www.python.org/doc/
  • 23. Kaizen Daily homework http://planet.python.org/ http://twitter.com http://plus.google.com ... Don't be afraid of asking help Any pythonista around Mailing list IRC http://stackoverflow.com http://www.python.org/community You are here, and this is nice!
  • 24. YOur friend PDB Get in touch with your gears
  • 25. Debugging A nice writeup to start playing with PDB: http://pymotw.com/2/pdb/ Search for PDB in PyPI: https://pypi.python.org/pypi?% 3Aaction=search&term=pdb+debugger&submit=search Search debugging tools for your app on PyPI!
  • 26. No more print
  • 27. Logging Logging is an important part of your code!
  • 28. Exceptions EXCEPTIONS ARE an important part of your code!
  • 29. How good is your code? https://pypi.python.org/pypi/pep8 https://pypi.python.org/pypi/pyflakes https://pypi.python.org/pypi/PyChecker https://pypi.python.org/pypi/pylint
  • 30. Use PYPI - The Cheeseshop https://pypi.python.org/pypi https://testpypi.python.org/pypi
  • 31. Virtualenv https://pypi.python.org/pypi/virtualenv http://docs.python-guide.org/en/latest/dev/virtualenvs.html http://www.buildout.org/
  • 32. Forget backup copies ● bazaar (bzr) ● git (git) ● mercurial (hg) ● subversion (svn)
  • 33. You can choose your place No warranty about qualitY of life... ● - http://bitbucket.org (git, hg) ● - http://code.google.com (git, hg, svn) ● - http://github.org (git, svn) ● - http://launchpad.net (bzr)
  • 34. Tickets!
  • 35. A quite comprehensive list http://en.wikipedia.org/wiki/Comparison_of_issue-tracking_systems A ticket aggregator https://pypi.python.org/pypi/bugwarrior
  • 36. Tests
  • 37. Be agile!
  • 38. Measure twice, cut once!
  • 39. SCALABILITY Will your application handle... ... more data? ... more users? ... more REQUEST?
  • 40. Fail fast!
  • 41. The times I was bitten by Python!
  • 42. alessandro.pisa@redturtle.it http://blog.redturtle.it @ale_pisa
  • 43. Nerd wars ● Use the Source, Luke ● The Source will be with you, always ● The Source is strong with this one ● May the Source be with you https://pypi.python.org/pypi/jedi
  • 44. Some random tips Use builtins! all, any, filter, map, sum, zip, ... http://docs.python.org/3/library/functions.html Code like a Pythonista! http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html Context managers! http://www.python.org/dev/peps/pep-0343/
  • 45. Use comprehensions [ale@padme presentations]$python3 >>> [x for x in range(10)] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> (x for x in range(10)) <generator object <genexpr> at 0xb7187234> >>> {x for x in range(10)} {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} >>> {x:x for x in range(10)} {0: 0, 1: 1, 2: 2, 3: 3, 4: 4, ..., 9: 9}
  • 46. Logging from logging import getLogger logger = getLogger('Test logger') def abs_ratio(x, y): try: return abs(x / y) except: logger.exception('Error abs_ratio: %r, %r' % (x, y)) return -1 abs_ratio(1, None) abs_ratio(1, 0)
  • 47. Logging Error abs_ratio: 1, None Traceback (most recent call last): File "logexample.py", line 6, in abs_ratio return abs(x / y) TypeError: unsupported operand type(s) for /: 'int' and 'NoneType' Error abs_ratio: 1, 0 Traceback (most recent call last): File "logexample.py", line 6, in abs_ratio return abs(x / y) ZeroDivisionError: division by zero http://pymotw.com/2/logging/ http://pymotw.com/2/exceptions/