Re: Pythonic style involves lots of lightweight classes (for me)

2006-12-14 Thread bayerj
Hi, I think that tuples are the best and simplest approach for small structures. >>> songs = [("Paranoid", "http://...";), ("Christian Woman", "http://...";)] >>> for title, url in songs: ... print "%s: %s" % (title, url) ... Paranoid: http://... Christian Woman: http://... I think that python'

Re: Pythonic style involves lots of lightweight classes (for me)

2006-12-14 Thread Andrea Griffini
metaperl wrote: > The above program started out as a list of dictionaries, but I > like the current approach much better. There is even a common idiom for this... class Record(object): def __init__(self, **kwargs): self.__dict__.update(kwargs) This way you can use user

Pythonic style involves lots of lightweight classes (for me)

2006-12-13 Thread metaperl
I find it arduous to type dictionary['key'] and also feel that any data I create for a program deserves to have its operations tied to it. As a result, I often create lots of lightweight classes. Here's a small example: vlc = '/Applications/VLC.app/Contents/MacOS/VLC' class song(object): def