Tuesday, March 18, 2008

Learning Python

I'm a long time C developer. Basically I figure that anything that needed to be coded could be coded in C. I still hold that belief, but 7-8 years ago I came to the realization that while that may be true, it is not always the best answer. For project reasons at work I learned Fortran and began to recognize its value when it comes to math. For other project reasons I learn how powerful simple Unix scripts can be. So basically for the last 7-8 years I've seen Unix scripting as a steering tool, C for text processing, Fortran for math, and Java for object-oriented and gui tasks. But recently based on a number of article from Computing in Science and Engineering (CiSE) I've come to learn about Python.

Python is a scripting language at its core, but overall it is much more. Python has a variety of modules and add-ons. Some basic include modules include NumPy/SciPy for math and science, CSV for delimited text, and XML for xml parsing and generation. My first Python program took me only a day or so to develop and test, it was a CSV translator. Basically it converted one CSV file into another. My next program took me another 2-3 days and it converted a gridded file into a CSV formatted file. And today, I wrote my first XML parser. Using 'minidom' from the xml package I was able to put together a simple parser for converting an XML file into a csv file.

All this I've basically accomplished over a few weeks of learning using only a handful of simple resources both online and in print. Yes I have many years of experience with a variety of programming languages, but I definitely have found Python the easiest to learn yet. Here is a quick list of resources I've found helpful:
I've bookmarked a number of other sites for future use but have not gotten to them yet. My next task will be to add a simple XML version of the gridded data file mentioned above, plus add NetCDF writing support and GIS writting support, namely ESRI Shapefiles. I also plan on learning howto wrap my C packages with Python binding. To put it plainly, things that I've spent years developing and testing in C for parsing weather related data, will all slowly be phased out and replaced with python code and modules and all opensource.

update 2008-03-19: added 2 more links

No comments: