May 06, 2008 13:40
This post is really only direct at Jason, so everyone who doesn't give a crap about programming can tune out, I guess.
I was writing some Python code that was parsing an xml file that had woe take data in. So each take looked like this:
I wanted to compile a list of all the guilds that had taken, so I created an array and wrote a loop. After some head bashing and some searching, I found out that the code to check if a value is in an array is SO BEAUTIFUL. Here it is(note, comments in Python start with a #):
#Store the guild name in a string
#This is just some xml parsing business
guild = attributes['guild']
#guilds[] is an array container all of the guilds that have taken
if guild not in self.guilds:
self.guilds.append(guild)
Isn't it beautiful??