mattbell: (Default)
[personal profile] mattbell
For a while I've wanted to be able to effortlessly play with the gobs of data floating around on the Web.

Although I have a computer science degree, I haven't done much programming over the last several years.  What I have done has mainly been C++ with a little tiny bit of Perl. 

This past weekend, I decided to learn Python.  I'm now finished with the 600 page long and fairly poorly written "Learning Python" O'reilly book.  The book tries to appeal to both people who don't have prior C/C++/Java programming experience and people who do, and the result is a meandering mess of text that would confuse the hell out of any introductory student while providing lots of noise to experienced programmers.  For slightly more work (or perhaps even less work and intellectual agony for the author) they could have just printed two versions of the book.  The author also had the bad habit of bringing up what I can only assume are very rare use cases very early in the book.  So you're getting exposed to advanced topics in, say, classes, only a few pages after seeing them for the first time.  The book also spend almost no time talking about best practices for code formatting and documentation. 

My impresion of Python is that it makes a lot of things that are horrendously awkward in C/C++ much simpler, both conceptually and syntactically.  The use of dynamic typing opens up a lot of possibilities for the language to be very flexible and conceptually elegant.  It also looks like there are a ton of tools to do exactly what I want -- play around with data off the web.

However, I can see all kinds of weird conceptual bugs popping up.  While C/C++ leaves you lots of low-level ways of shooting yourself in the foot, Python enables lots of ways for you to abstractly and conceptually shoot yourself in the foot.  I can see lots of mistakes popping up with shallow vs deep copies, incorrect scoping of variable assignments, and accidental manipulation of function and class objects.

I'm curious about the experiences of others who've played with Python.  I'm going to start using it to play with Flickr data.







Date: 2009-07-15 07:48 am (UTC)
From: [identity profile] proctologiste.livejournal.com
Long time pythonista here.

http://diveintopython.org/toc/index.html is a much better introduction into what python should feel like. It covers an older version (I think it's 2.4 compatible) but it's mostly accurate.

Yes, you can box yourself into the corners you mentioned but in my experience, it is harder and much less common that the various C low level issues.

If you're writing data mining applications that can grow unexpectedly, I highly recommend using doctest as you go to make sure the various functions that each do something small operate properly. In case the book doesn't cover doctest: lets you embed mini unit tests into the docstring, just type the expected interaction with the interpreter for this function into the docstring.

Date: 2009-07-15 09:54 am (UTC)
From: [identity profile] proctologiste.livejournal.com
Yeah!

Highly recommend going through the module listing. There are some hidden gems.

Just yesterday found out there's a built-in module to convert hsv to rgb and such things (colorsys).

Also, you should really learn and know the itertools method. Invaluable.

Date: 2009-07-15 09:54 am (UTC)
From: [identity profile] proctologiste.livejournal.com
erm, module.

Date: 2009-07-15 06:56 pm (UTC)
From: [identity profile] spoonless.livejournal.com
I've been wanting to learn Pyton too, I started reading a tutorial on it a couple months ago and have been looking for a chance to continue reading and playing around with it.

It seems like when I was actually doing programming professionally, python was still relatively obscure, and more people used Perl for doing things with a high level of abstraction and flexibility. Then at some point I switched into science and only do programming occasionally, during which python seems to have become extremely popular and perl has fallen more by the wayside. So now I figure it's pretty important to pick up.

Profile

mattbell: (Default)
mattbell

February 2011

S M T W T F S
   123 45
67 89101112
13141516171819
20212223242526
2728     

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 31st, 2025 02:35 am
Powered by Dreamwidth Studios