Feb 14 2012

Learning the basics of Python in an evening

I decided to enroll the free two courses delivered by Udacity: Building a Search Engine and Programming a Robotic Car. There will be programming contests and the language used will be Python. I never programmed in Python before and so I decided to start learning the language.

If you already know a language like Java, C# or C++ learning Python is relatively easy.

I started to quickly read the official tutorial:

I think that it is quite good as a starting point and teach you all the basics: control flows, data structures, modules, input and output, errors and exceptions, classes and standard library.

An another interesting resource is Learning Python in 10 minutes. This collects in a single post the basic Python syntax.

After the following reading I decided to start doing a simple coding session. I decided to implement a Code Kata and in particular the Kata Four: Data Munging.

First of all, I installed the python engine:

I decided to use the version 2.7 instead of the latest 3.2. It seems that the latest is quite recent and there are lots of breaking changes and the conversation process of many libraries is still in progress.

The next step is installing the development environment. It seems that there is a unproportional list of editors out there to develop in Python. I personally love Visual Studio and the idea of a single integrated environment and for this reason I found a Python extension for Visual Studio that was perfect for me:

Ready !!!

You can create a new project in the usual way:

and start adding files in the solution explorer:

The tool has also some good intellisense that helps in writing code. Considering that Python is a dynamic language this is quite impressive.

Here few examples:

This is an extract of the code:

You can find the complete source code in my personal repository:

I think that the best way to learn Python is using it. I am looking forward to play with it during the courses.

Permanent link to this article: https://www.productivecsharp.com/2012/02/learning-the-basics-of-python-in-an-evening/