I decided to learn Python and Django in the hope that it would be a halfway house between PHP and Lisp, letting me get stuff done while not being PHP.
My first impression of Django was pretty negative. I bought the ‘definitive guide’ book only to find it was not so much definitive as obsolete. Also, the amount of arbitrary-seeming magic didn’t impress. Having said that I have passed through that and I’m beginning to get the hang of it.
Python, on the other hand, was different, to start with I HATED the look of the code compared to Lisp but after a few hours hacking it doesn’t seem that bad. For my first program, I decided to solve this little puzzle. This excellent guide got me going quickly and along with a few small pointers from verte in the friendly-seeming #python I came to a solution.
def draw_diamond(letter): alphabet = 'abcdefghijklmnopqrstuvqxyz' size = alphabet.find(letter) for x in range(size) + range(size, -1, -1): line = [' '] * ((2 * size) + 1) line[size + x] = alphabet[x] line[size - x] = alphabet[x] print "".join(line) draw_diamond('d')
It didn’t take long, the code looks nice and most importantly I enjoyed writing it. I’m pretty impressed!