I was building a list of media resources (eg. photos, videos) when I found myself writing the following code to sort that very list:
[code lang="python"] getdatetime = itemgetter(’datetime’) media.sort(key=getdatetime, reverse=True) [/code]
It’s not rocket science or anything new but this time I thought the above code lying beneath the expression “code beautiness” (for the record: itemgetter sits in the operator module and media is a list of dictionaries).
So, what’s your example of code beautiness? What python idioms do you find beautiful and maybe “superior” than equivalent in another language?
