Introduction to Python

What is Python?

Innumerable technologies and programing languages are available for developers to learn and master. A life time may not suffice to learn them all! But, Techies still have the inner urge to learn and master newer and newer technologies - for the fun.
Python is one such language that is easy to learn and fun to code. Python has inherited the best of the practices from its counterparts, and has corrected a lot of issues they contain. Python is fun, Python is easy and Python is rich! It is backed by a huge open source community that ensures extensive support. It is ideal for rapid prototyping and fast development.
This series of tutorials on Python were compiled as I was trying to learn the language. I will present them here, for someone who might want a quick introduction to the language, without digging through all the manuals. This is not a 'Complete Reference' nor is it a 'Python for Dummies'. It is meant for someone who understands development and wants to peep into the world of Python.

General Knowledge

Python is an interpreted language, originally created by Guido van Rossum. The development for Python started in 1989, Python has now come a long way, and is backed up by a huge community. Although it has been around for ages, it has acquired a lot of popularity in recent years.
Python itself is coded in C - hence it is also called CPython. There are other similar products coded in other languages - e.g. Jython coded in Java, Iron Python coded in C#. But, CPython continues to be the most popular. Python was developed with one major philosophy in mind - to make the code easy to read, easy to maintain and easy to reuse. In that sense, it does deviate from other common languages like C/C++/Java/Perl, etc. We will see that in detail as we proceed.
It is an interpreted language. The source code is interpreted by the Python interpreter at runtime and not precompiled. That may add a bit to the performance overhead. But, it helps the maintainability. One can argue endlessly on the pros and cons of either side of the tradeoff. The developers of Python chose this side, and it works well for the purpose that Python was meant.
Python is object oriented to the core, and it makes reuse absolutely easy. That is the one of the major reasons why Python is growing in popularity. Python has tons of ready to use modules and hundreds of frameworks that help support development for wide range of applications running on enterprise web applications, general desktop applications, embedded controllers, etc.
Python Specialization from University of Michigan
Python has seen 3 major releases so far, and several minor versions. Both Python 2 and Python 3 continue to be popular today. Python 3 is a major branch and not fully backward compatible hence many developers prefer to carry on with 2. But that number is slowly decreasing and 3 is getting more and more popular. As they say, Python 2 is the past, 3 is the future. I preferred to start with Python 3. Don't ask me why! When I typed this page, Version 2.7.12 and 3.6.2 were the latest in the respective series. I have version 3.6.2 installed on my machine and all my examples are targeted for 3.6.2
There are several books and tutorials on Python. But, in terms of completeness and clarity, I have not come across anything better than the Python Tutorial provided by the Python community
Ok! I think we have spent enough disk space on a long introduction. Now, let's get started!

Getting Started

There are many different sources and distributions of Python. Foremost is available on their own site Install Python. This page has everything you need. Download the version you like. We also have other distributions like Anaconda that package a good amount of useful stuff along with the base Python. This is what most enthusiasts use. And then there are other commercial distributions of Python like ActiveState Python that charge you for support and packaging. That is meant for people who prefer to spend money.
Python comes with its own editor (IDLE) that provides syntax highlighting. It is good for developing and running minor scripts and also for testing single commands. But, for doing anything more complex and useful, you will need a better IDE. Several open source IDE's are available on the net. The list keeps growing. Just lookup one you like from Google and you should be ready to go. I like Spider and Atom. If you don't like these, just search for one on the net and let me know if you find something useful.
Eclipse has a plugin for python development and that is the one I use. Visual Studio too has an extension for Python. If you are an Eclipse fan, (use a decently upgraded version - not the age old Galileo) go to Help - Eclipse Marketplace - Search for PyDev - Install. With this setup on your machine, you are all set to go!


We often put in a lot of effort on Traditions. We do a lot of things we don't really know why, but we do them because "that is the way"!
The "Hello World" is another such tradition. None knows what is so magical about those two words. But there is something so magical that everyone wants to use just that phrase. Possibly something to do with the time tested mantra of developers - ^C + ^V!! Anyway, let's do the same here - announcing to the world that we have started learning Python.Open your IDE and create a new Project - Learn Python or HelloWorld; Create a new file with the appropriate extension (.py).
If you are running on Windows, the extension should be enough. But if you are fond of Linux, the extension has no meaning. You need to explicitly indicate the interpreter using the shabang on the first line of the script. After that, add the following one line in the new script.
print("Hello World")
That is all we need in order to start. The code prints the two words - Hello World - Nothing much for the world, but it does tell you that you have started well!