Sunday, March 18, 2018

Recommended Resources for Learning Python

Python is an easy programming language yet powerful. It's my favorite language so far and one that I have used professionally for the past 5 years since I learned it at LinkedIn. To help others learn the language, I thought I would recommend a few good resources.

The best way to learn Python, like anything else, is to read the official docs/tutorials, other people's code, and then tinker!

Docs / Tutorials


The best resources for Python are on the python.org website itself, especially the Python for Beginners collection. A Byte of Python is a good beginner's book that explains concepts well -- note that it does have one bad example of using bare try/except. Otherwise, Google is your best friend. Just google Python followed by a few keywords of what you want to do. E.g. Search "python open files" to see how to open files.

I have also started a Python code examples repository that will help you learn faster by providing code that can be easily run and tinker with.

IDEs


A great editor makes all the difference in how productive that you can be.
  • Vim is what I use and highly recommend it. With the right setup, it's a pretty powerful IDE for Python -- lean & mean. Take a look at a few guides on how to setup by googling "vim python ide". Or feel free to take my setup for a spin as I have dockerized my IDE at https://github.com/maxzheng/ide
  • PyCharm is also a pretty good editor from JetBrains that you can just install and start using. This is recommended for newbies or those that are used to a full featured IDE using a mouse.

Interactive Shells


Using a shell is a great way to inspect and tinker with a code snippets!

  • python - After you have installed Python, it already comes with an interactive shell that you can use by running python. I use this all the time.
  • iPython - It's a more powerful and featured version of the default python shell. It is slower to start, which irks me, and so I personally just use the default python shell.
  • python.org has an online shell for Python 3 from PythonAnywhere, which also has an online shell for iPython.

Debugger


  • pdb - The Python Debugger module. It's simple and works well. Aside from print statements, this is what I use the most to inspect variables and debug code. 
  • winpdb - If you need to attach to a running Python process, this will do the job. 
  • PyCharm comes with debugging capabilities too if you are using that.

Repository


One of the great things about Python is its extensive packages repository called Python Package Index (PyPI) with contributions from everyone around the world. It's easy to use and contribute. I have published a few packages myself. You can install any of the packages by using pip.

This is part of the Technology blog series.

No comments:

Post a Comment