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

Comrade 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

An annual note to all the (NSF) haters

It's that time of year again: students have recently been notified about whether they received the prestigious NSF Graduate Student Research Fellowship. Known in the STEM community as "The NSF," the fellowship provides a student with three years of graduate school tuition and stipend, with the latter typically 5-10% above the standard institutional support for first- and second-year students. It's a sweet deal, and a real accellerant for young students to get their research career humming along smoothly because they don't need to restrict themselves to only advisors who have funding: the students fund themselves!
This is also the time of year that many a white dude executes what I call the "academic soccer flop." It looks kinda like this:


It typically sounds like this: "Congrats! Of course it's easier for you to win the NSF because you're, you know, the right demographic." Or worse: "She only won because she's Hispanic."…

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 do was p…

Culture: Made Fresh Daily

There are two inspirations for this essay worth noting. The first is an impromptu talk I gave to the board of trustees at Thatcher School while I was visiting in October as an Anacapa Fellow. Spending time on this remarkable campus interacting with the students, faculty and staff helped solidify my notions about how culture can be intentionally created. The second source is Beam Times and Lifetimes by Sharon Tarweek, an in-depth exploration of the culture of particle physics told by an anthropologist embedded at SLAC for two decades. It's a fascinating look at the strange practices and norms that scientists take for granted.
One of the stories that scientists tell themselves, whether implicitly or explicitly, is that science exists outside of and independent of society. A corollary of this notion is that if a scientific subfield has a culture, e.g. the culture of astronomy vs. the culture of chemistry, that culture is essential rather than constructed. That is to say, scientific c…