Posted: February 13th, 2010 | Author: ryan | Filed under: Django, Python | Tags: Django, Python, Web Development, Web Framework | View Comments
I had started reading The Django Book a while back but couldn’t get into it. I had been around a lot of Rails folks recently, mostly The Collective, and succumb to geek pressure to choose Rails over Django. Being a Python guy myself, it was a hard sell. I never did anything especially cool with Rails until recently (more on that to come sometime)
Less than a week ago I bought The Definitive Guide to Django: Web Development Done Right. I prefer to read a hardcopy; for me hardcopy > HTML > PDF (in most cases).
I’m about halfway in and have noticed a handful of issues. Apparantly, I’m not the only one. Notkeepingitreal.com has covered the issues in the first few chapters.
Posted: January 26th, 2010 | Author: ryan | Filed under: Hadoop, Python | Tags: AAS, poster, posters, talk, talks | View Comments
I think I might have more draft posts than published ones. That’s kind of sad. I’m going to try and ease the pain, if only just slightly, right here right now.
I had started writing a post while I attended Big LAMP Camp in Nashville, TN back in early November 2009. The conference and camp were a lot of fun and well attended. I met a lot of great people. The list of speakers shows just goes to show how the traditional LAMP stack has evolved to include languages besides PHP (Ruby and RoR had a strong showing). Although I was the lonely Python developer. My talk was about how Galaxy Zoo is using Python and Hadoop to process large astronomical data sets.
More recently I traveled to Washington D.C. with other members of the Galaxy Zoo team to the 215th meeting of the American Astronomical Society. There I presented a poster on the same topic.
Posted: July 17th, 2009 | Author: ryan | Filed under: Python, Tips and Tricks | View Comments
Here’s a nifty generator to take a list, l, of length n and get each of n sublists, l[0:i], where i ranges from 1 to n+1.
1
2
3
4
5
6
7
8
9
10
| def gen_sub_lists(l):
"""Generate sublists of a list.
Sublists of [0,1,2,...,n] are
[0], [0,1], [0,1,2], . . . , [0,1,2,...,n].
"""
lengths = range(len(l))
for end in lengths:
yield l[0:end+1] |
Posted: July 9th, 2009 | Author: ryan | Filed under: Fortran, Python | Tags: Fortran, Python, xkcd | View Comments
I want to write more. I’d really like to write for Python Magazine, but I don’t have any ideas for a topic yet. Matt opened a can of worms by asking me why he should bother to learn Python as a Fortran alternative.
Both Matt and myself come from a Fortran background. At ISU, all physics majors were required to take a formal class in Fortran programming. Note only that, the vast majority of physics courses (all sophomore level courses and higher, except education courses) assigned computational homework sets or projects. It wasn’t always required to write your code in Fortran but pretty much everyone did. I always preferred coding in Fortran over C/C++ and I never really got into other languages as deeply as I did with those. I’ve even read many pages of the Fortran specification. Yeah. I used to really like Fortran, and defended it fiercely. I still do when I encounter someone who claims it is dead or useless. Bah! The truth is quite the contrary.
That said, I don’t write anything in Fortran. Not since Python. Now, getting back to Matt’s question, I don’t have a itemized list of reasons. Put simply, Python is simple. Consider these short examples.
Python
1
| print "Hello from Python" |
Fortran
1
2
3
| program hello
print *, "Hello from Fortran"
end program hello |
To say Hello from Fortran takes three lines, opposed to just one in Python. More importantly, the Python code just makes sense. It’s almost so simple that one could guess the syntax. This is true for a lot of things in Python.
And what the heck is going on with the asterisk? It looks like the print statement is to print two things: something that goes by the name ‘*’ and a string literal. Could it mean print everything, and the string? No. The print statement takes as its first argument the output device, in this case the default stdout. The integer 6 would work as well. To print to stderr or read from stdin you would use 0 and 5 respectively. The POSIX file descriptors for stdin, stdout and stderr are 0, 1 and 2 respectively.
To drive this home and to poke fun at myself I’ll admit that couldn’t remember how to use the fortran print statement. There were several unsuccessful attempts at compiling my three-liner before I turned to Google and was reminded to include the output device.
I need to sit down and think about a more detailed answer to Matt’s question. But until then check out this XKCD comic titled Python.

Python by XKCD