Now that I'm using Python for a large percentage of my development, I thought
it would be fun to highlight a few reasons why Python has become my new
language of choice.

In an effort to help you understand where I'm coming from, let me
briefly rehash some of my programming history: I spent much of the
90's doing dynamic web development using Perl (weren't those the
days). I eventually migrated to PHP which usually made things much
easier on the web; and subsequently replaced most of my console
scripting with BASH [shell scripting]. However, I'm kind of a hack and
love languages so I have occasionally been known to write something in
C; and although I'm not a complete stranger to Java and Ruby, I never
really felt like I "clicked" with either of those languages.

Ok, now that I've hopefully convinced you that I'm not just a
fly-by-night programmer, let me show you some Python code. Brace
yourself, as this article is bound to get lengthy...

Reason #1: "Whitespace done right" is actually a good thing

The first thing that people either absolutely love or adamantly hate
about Python is the fact that its syntax is heavily tied to proper
usage of whitespace. At first glance, this causes many curious onlookers
from other languages to shy away from Python and continue in their
brace-encapsulated bondage. I'll admit, at first I wasn't too wild
about these new restrictions either (I'm a programmer—I should be able
to format my code how I like!); but the first time I had to go back and do
something in PHP for a client, I quickly realized I never wanted to wrap
anything in curly braces again:

# An example function that's free from braces, (some) parenthesis, and semicolonsdefcheck_number(x):iftype(x)!=type(0):return"That isn't a number!"elifx%2:return"This number is odd"else:return"This number is even"

Not only does this make Python source code incredibly readable, but you
also end up typing less.

Reason #2: I almost always know what type of object I'm working with

One thing that always annoyed me about Perl was that you set an array or
hash using the '@' or '%' sigils, but typically accessed them using the
'$' sigil. PHP simplified this a bit, but "$array = array();" could be a
simple list or an associative array (known as a dictionary in Python).
With Python on the other hand, the enclosure defines the type (for most
built-in types at least), and since everything is an object there's no
need for silly sigils:

# the type of enclosure makes a distinction between a string , a list, and a dictionarystring='This is a string'printstring# prints 'This is a string'list=['This','is','a','list']printlist[0]# prints 'This'dict={'first_key':'This','second_key':'is','third_key':'a','fourth_key':'dictionary'}printdict['fourth_key']# prints 'dictionary'

On a somewhat related note, you can use these objects on-the-fly in your
scripts without even having to assign them:

This isn't very practical of course, but it can be nice when debugging.

Reason #3: I can throw practically any type of object almost anywhere I want

Ok, so that might be a slight exaggeration; but the truth is that since
Python treats everything as an object, you're free to pack things away
in the strangest of places. A great way of demonstrating the power and
flexibility of Python is in an example showing a few ways different
types of objects can be stored and accessed:

As you can see, Python is a flexible, powerful, and even fun programming
language. For more Python concepts (I didn't have time here to go into list
comprehensions, generators, decorators, etc), I'd suggest you take a gander at
Wikipedia's page on Python syntax and
semantics.

Finally, I'll leave you with a few relevant links that are worth taking
the time to check out: