Monday, February 13, 2012

My secret weapon... Python

I came across this blog post the other day "Why Python is important for you" . It felt like he read my mind. I was going to have a similar post explaining why I believe everyone should learn at least basic Python coding. But since he wrote it up so well I let you just read it "why" and instead I tell you my love affair with Python and why I it is my secret weapon.

I use Python for my work every day. I write all the backend software for clients iOS apps using the Django framework. Also use Python extensively to talk to 3rd party APIs and collect/crunch data. Automate a lot of things that the software needs to do without user interaction. It is ridicules how simple to update a bunch of file, replace code in them. And python has a Giant standard library you can use and it pretty mush covers everything, or as they say Batteries Included.:) But if you still not convinced look at all the places python used, also MIT switched to Python from Scheme.

My love for Python started back in 2003 although I started to use it in 2002 to parse log files. Switching from Perl to Python was an awesome experience. We got our first digital camera and taking a lots of picture. But when downloaded to the computer we had a couple hundred images with IMG_00433 etc.. My wife organized them into folders using the thumbnail view but it was still tedious. So to make my life easier by making hers easier:) I opened up python prompt and started to hack out a quick renaming script. She loved it. now it took no time at all to rename a bunch of images and she could even provide the prefix "birthday_". Then she was mad since some of the images needed rotating, no problem there is a battery for that, lets get PIL add an other function, an other command line question if she wants auto rotate. Done. It was so painless and fast to implement that for awhile I was certain that everyone wrote a script like that just like everyone wrote at one point "Hello World".
Well it wasn't the case and there was a lot of happy people around me using this simple tool.
That's when Python became my secret weapon, and it is ever since. 
Well, not so secret anymore...

If you haven't touched python yet go and open up your terminal if you are on a Mac or Linux and type in at the console$ python and start playing. On windows just download the installer and you are a few clicks away.
Python uses white-space indentation instead of curly braces which makes the code beautiful and reading it a pleasure.