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

A view from your shut down

The Daily Dish has been posting reader emails reporting on their " view from the shutdown ." If you think this doesn't affect you, or if you know all too well how bad this is, take a look at the growing collection of poignant stories. No one is in this alone except for the nutjobs in the House. I decided to email Andrew with my own view. I plan to send a similar letter to my congressperson. Dear Andrew, I am a professor of astronomy at the Harvard-Smithsonian Center for Astrophysics (CfA). The CfA houses one of the largest, if not the largest collection of PhD astronomers in the United States, with over 300 professional astronomers and roughly 100 doctoral and predoctoral students on a small campus a few blocks west of Harvard Yard. Under the umbrella of the CfA are about 20 Harvard astronomy professors, and 50 tenure-track Smithsonian researchers. A large fraction of the latter are civil servants currently on furlough and unable to come to work. In total, 147 FTEs

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