Skip to main content

Taking the Python Plunge


I'm finally doing it. I'm learning Python through Codecademy's online tutorials.

So far, I really like Python. Everything is natively object oriented, so every variable is born as an object. Working within the paradigm has already shown me how much time I spend wrestling with IDL to make it work more like an object-oriented programming language, when it simply isn't. I've been known to call my style within IDL as Pseudo Object Oriented Programming, or POOP. It's often just as ugly as it sounds. So, philosophically, I'm finding that Python is well aligned with my programming style and needs.

Big ups to my student, Tim, for helping me with some of the nuances of Python arrays and syntax. He also pointed me to the Enthought Canopy programming environment, which is a great way to write code. Think of it as IDL's Development Environment, but less clunky.

I'm planning to start a new research project built solely on Python. It's a bit daunting, but I figure the only way to learn is to dive right on in. If you have any encouragement to lend, I could use it!

BTW, the Codecademy tutorials are a lot of fun, too. Here's a little easter egg that one of their "PSAs" alerted me to:


In [1]: import this
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

Comments

Tom Rice said…
Great to hear you're moving to Python! Some resources I really like:
Python 4 Astronomers: http://python4astronomers.github.io/

Astropython blog:
http://www.astropython.org/

Astropy project: http://www.astropy.org/

Astropy user mailing list: http://mail.scipy.org/mailman/listinfo/astropy

and the CfA maintains a useful internal pythonusers mailing list (Tom Aldcroft should be able to point you to it).

Popular posts from this blog

back-talk begins

me: "owen, come here. it's time to get a new diaper" him, sprinting down the hall with no pants on: "forget about it!" he's quoting benny the rabbit, a short-lived sesame street character who happens to be in his favorite "count with me" video. i'm turning my head, trying not to let him see me laugh, because his use and tone with the phrase are so spot-on.

The Long Con

Hiding in Plain Sight ESPN has a series of sports documentaries called 30 For 30. One of my favorites is called Broke  which is about how professional athletes often make tens of millions of dollars in their careers yet retire with nothing. One of the major "leaks" turns out to be con artists, who lure athletes into elaborate real estate schemes or business ventures. This naturally raises the question: In a tightly-knit social structure that is a sports team, how can con artists operate so effectively and extensively? The answer is quite simple: very few people taken in by con artists ever tell anyone what happened. Thus, con artists can operate out in the open with little fear of consequences because they are shielded by the collective silence of their victims. I can empathize with this. I've lost money in two different con schemes. One was when I was in college, and I received a phone call that I had won an all-expenses-paid trip to the Bahamas. All I needed to d

Reader Feedback: Whither Kanake in (white) Astronomy?

Watching the way that the debate about the TMT has come into our field has angered and saddened me so much. Outward blatant racism and then deflecting and defending. I don't want to post this because I am a chicken and fairly vulnerable given my status as a postdoc (Editor's note: How sad is it that our young astronomers feel afraid to speak out on this issue? This should make clear the power dynamics at play in this debate) .  But I thought the number crunching I did might be useful for those on the fence. I wanted to see how badly astronomy itself is failing Native Hawaiians. I'm not trying to get into all of the racist infrastructure that has created an underclass on Hawaii, but if we are going to argue about "well it wasn't astronomers who did it," we should be able to back that assertion with numbers. Having tried to do so, well I think the argument has no standing. At all.  Based on my research, it looks like there are about 1400 jobs in Hawaii r