11 Common tricks used by Senior Python Developers for Novice

Are you a Python developer looking ahead to sharpen up your skills? Here are 11 tips from a Senior Developer to make you an expert in your field.

11 Common tricks used by Senior Python Developers for Novice
geralt / Pixabay
  1. Use Python 3.6, there are some significant improvements over 2.7 – like enums and fstrings (I would switch to 3.6 just for fstrings, TBH)
  2. .open() or .close() is often a code smell – you probably should be using a with block
  3. Use virtualenv for every project – don’t install python packages at the system level. This keeps your project environment isolated and reproducible
  4. Use the csv module for CSVs (you’d be surprised…)
  5. Don’t nest comprehensions, it makes your code hard to read (this one from the Google style guide, IIRC)
  6. If you need a counter along with the items from the thing you’re looping over, use enumerate(items)
  7. If you’re using an IDE (as a Vim user I say you’re crazy if you’re not using Pycharm with Ideavim) take the time to learn it’s features. Especially how to use the debugger, set breakpoints, and step through code
  8. multiprocessing not threading
  9. Developing with a REPL like ipython or Jupyter alongside your IDE can be very productive. I am often jumping back and forth between them. Writing pure functions makes them easy to test / develop / use in the REPL. ipython and Jupyter have helpful magics like %time or %prun for profiling
  10. Use destructuring assignment, not indices, for multiple assignments first, second, *_ = (1,2,3,4)
  11. Avoid *args or **kwargs unless you know you need them – it makes your function signatures hard to read, and code-completion less helpful

Learn how to code in Python Language by coding robots to Kill Zombies.


Get 60% off from SiteGround.com when you buy their Web hosting service using the link provided here. More Less