Thanks to lambda expressions, PyGTK coolness and getattr, i.e. accessing attributes by name, this dialog is now quite customizable and the code is still readable and (compared to what other languages would have yielded), small. If you are using gPodder, be sure to check out the current SVN trunk head.
One feature I used several times was enumerate() - you give an iterable as parameter, and get a generator that yields tuples with two elements - a zero-based index and the values you would normally get from the iterables directly. So, instead of writing code like this:
index = 0you can simply write
for item in items:
print 'item %d is %s' % ( index, item )
index += 1
for index, item in enumerate( items):which isn't only nicer, but you save two lines and the code is IMHO more readable (you instantly recognize "index" as being related to the for loop in the second code snippet).
print 'item %d is %s' % ( index, item )
1 comment:
This looks like a nice improvement!
I'm updating SVN as we speak... :-)
Keep up the good work!
Post a Comment