Why I ♥ Python

I had a few encounters with Python before I followed the Introduction to Interactive Python programming courses of Rice University via Coursera. I remember the struggles when I tried to program Twitter feed analysis code with Python on the Introduction to Data Science course I did two years ago. I eventually had to give up. And on the Hadoop Platform and Application Framework course I couldn’t solve one of the problems with Python and eventually, with the deadline looming, used Excel to find the right answer. That’s right: I solved a Big Data problem with Excel (because there wasn’t a lot of data).

But ever since I’ve followed Rice University’s first Python course, I was hooked. Python is a pretty easy language, once you know the basics. But that’s not the only reason I love it. You can use it almost everywhere. Examples?

  • In Big Data and Machine Learning you’ll find Python everywhere. You can code old fashioned mappers and reducers or you can talk Python against the hip and happening TensorFlow for machine learning.
  • In Oracle Fusion Middleware you can use Jython. It’s Python, but compiled in Java. Also you can use Python in combination with Enterprise Manager’s command line tool emcli.
  • For Google’s cloud services there are a myriad of Python API’s. I’m not saying they are easy to learn (I’m still struggling to upload photo’s to Google Photo), but the opportunies exist.
  • I’ve discovered I can program the motorized mount of my telescope with Python. People have written a library for that.
  • You can use Python in the video game Kerbal Space Program. This is a space simulator and I’ve managed to bring a spaceship in orbit automatically.

 

Libraries

One of the great things about Python is that you can very easily install new libraries. Want to install TensorFlow? Just do this:

pip install tensorflow

And all you have to do now is do something intelligent with it.

Want to use Python against an Oracle database?

pip install cx_oracle

Off you go. Python libraries easily come and go (pip uninstall …) as you please.

 

Handling data

Of course Python is very popular in Big Data, because it’s so easy to handle data with it. Take for example this little home project I’m working on. I want to write a program to upload photo’s from my last holiday and upload those photo’s to Google Photo that are not yet there.

First I had to find all the JPGs I’ve rated of 4 stars or higher in Adobe Bridge CS5. That seems an easy task, but it took me some time to find out where that rating is stored and what Python library I needed. At a certain point I found pyexifinfo. It’s a library that is a wrapper for a program called Exiftool.

So let’s say I’ve stored the XMP metadata (which is stored in the JPG) in a variable called metadata. Now, what is this data like? We’ll just do this:

print type(mymetadata)

And it returns:

<type 'list'>

In the list there was another data type, a dictionary (which you can find with the same command). Dictionaries is a type where data is stored in key-value pairs. And the great thing is: XMP:Rating is one of those keys. All I have to do to get the rating is do this:

if mymetadata["XMP:Rating"] >= 4:
    <now upload the file to Google Photo somehow>

I don’t know about you, but I like that. Another data type I like, is sets. Sets is like a list of values, but they are unique. That’s often pretty useful.

Learning Python

I’ve already mentioned the course from Rice University via Coursera.org. It’s a good and fun course and I’m pretty sure that after Part 1 even, you’ll be enthusiastic about Python too.

Arup Nanda made a video and blog series called Python for PL/SQL developers. You might want to try that.

Currently I’m keeping my Python skills up to speed by training on hackerrank.com. They have many Python challenges (and Linux shell and SQL and many other things). Good for the skills and with the gamification features also good for the ego.

I’ve not even mentioned a fraction of the joy of Python or the things you can do with it on your Oracle or Hadoop or home environment. Go have a look.

Advertisements

About Marcel-Jan Krijgsman

Ever since I started working with Oracle, I had an interest in Oracle database performance tuning. This led, eventually, to a four day training I made and gave for customers of Transfer Solutions. Since 2012 I work for Rabobank Nederland. A few years ago I also became interested in Oracle database security. All technology aside, it is my experience that security usually plays out on a political level. I'm a Oracle certified professional for the 8i, 9i, 10g and 11g databases and Oracle Database 11g Performance Tuning Certified Expert.
This entry was posted in Python and tagged , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s