January 20, 2014

So you want to learn Python...

Last month, i’ve been posting and reading posts on G+ more than i did since i subscribed on it (almost 2 years).

The first thing i realized is that it’s that it’s awesome for learning and read thoughts on technos or project. The second was the amount of posts about learning Python. As i do not see myself as a Python expert (i’m so far from it at the moment), i think i have been dealing with the language and learned lot of things about it since i wrote my first #! /usr/bin/env python line. So, here i wanted to share my thoughts about my learning path and some links too.

Do not want to learn, just learn !

I’ve been wanting to learn Python for more than 2 months. And now i realize that it is a lot of lost time. Wanting to learn Python, or any other language after getting some resources to get started is just boring as there is not a defined list of resources to read. When i decided that it was high time i dive into Python, i just started with the Python official tutorial.

As far as i’m concerned, it’s one of the best resources for getting started. And even with other technos/projects unrelated to Python, if the website or documentation have Getting Started section, reading it is totally worth it.

The weird path: Learn from the top-level

When i started to learn Python, i was doing a lot of web development in PHP and was not really interested in system administration. So i first searched for Python-written projects to, let’s say, motivate me. Knowing that my favourite web applications (Dropbox and Pinterest) was written in Python boosted me as i’ve never been. After that, i searched for frameworks for web development and finally had to choose between Django and Flask. I choose Flask. Just because it was lightweight and looked like a great framework (nice doc, extensible…).

The reason i consider this way of learning weird, is that for all languages i learned, i went through a classic path: learn basics, write programs for whichPython could be a suitable language, write shitty programs you will never use only because they are in the tutorial, code advanced programs like games. But i could not use this method this time for 2 reasons:

  • You can do almost every type of program in Python, so «Python could be a suitable language» was not really valid in this case.
  • I was sick of writing games. We do that at school, in tutorials, everywhere. But i’m not a even a gamer so writing games is a torment.

What i want to say after all this long block of thoughts, is that the learning path can be different for you. And do not think that you are doing it wrong only because all people you met say they won’t learn this way. Follow the learning method used by others and not by you and you won’t learn anything.

Find a mentor

This is not always possible in the real world. It depends on your entourage. I’ve been learning Python as a student, but on my own. In 5 years of school, we have no Python courses, so i’ve been harassing my friend who told me about the language for a long time before going on my own. Thanks to him. If you can’t find a mentor in the real life, the guyz/gals on the Internet will be glad to help you. I’ve seen people on G+ answering at any kind of questions, from the ultimate beginner one, to the expert pythonista of the death one.

Github is your mentor

You still not find a mentor. I’ve discovered a guy named after Github that can help you. The best mentor i found the last year were… reading other’s code. This can teach you a lot of things. From patterns to best practices. And the projects there are often used in production. Pick a project you like, not the biggest one you find. Even if it’s 100 lines of code, if you can read them and explain what they do, it’s always better than the 32168 lines of code of the biggest project you find and do not even know what the half do.

Personally, i started with Flask, because i loved it and wanted to know more about the framework i used. I read the code, and i even knew WSGI implementations with it.

Read PEPs

I know, that’s weird. Many people read the PEP8 and other code presentation related PEPs. I want to read them all. After reading Python code for more than a year now, and understand what these codes do, i wanted to know WHY they do that. Python’s PEPs is the only system i know to be that open. 2 clicks to see all the PEPs when you are on the website’s homepage. This part may wait that you are already comfortable with Python, but hey ! Some does not even require a high level in understanding the language.

Be a mentor

This is probably the best way to learn: teaching. Trying to get people around be learn our language bring me into teaching them the basics, answer to their questions, even if i’m not an expert. Helping people helps you learn more and more each day. For example, questions about the encoding «problems» (not a problem, i think) have me learning lots of stuffs about encoding in general. Same thing with frameworks like Flask or Tornado and explaining WSGI interface to non web developers.

Here are some links that have been useful for me in my Python adventure (not many as you can notice): * Python’s tutorial * Python Web Frameworks * Codecademy Python course * Learn Python The Hard Way

comments powered by Disqus