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."…

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…

The subtle yet real racism of the Supreme Court

Judge Roberts, a member of the highest court in the land, which is currently hearing the sad story of mediocre college aspirant Abigail Fischer, recently asked, "What unique ­perspective does a minority student bring to a physics class? I’m just wondering what the benefits of diversity are in that situation?" 
Did you catch the white supremacy in this question? If not, don't feel bad because it's subtly hidden beneath the cloaking field of colorblind racism. (As for Scalia's ign'nt-ass statements, I'm not even...)
Try rephrasing the question: "What unique perspective does a white student bring to a physics classroom?" The answer is, of course, absolutely nothing! Why? Because race isn't biological, and is therefore not deterministic of cognitive abilities. Did you perhaps forget that you knew that when considering Roberts' question? If so, again, it's understandable. Our society and culture condition all of us to forget basic facts …