Newbie question about tuples and list comprehensions

Roger Miller roger.miller at nova-sol.com
Thu Jun 26 01:20:29 CEST 2008


First, I second Matt's comment about using a boring old for loop when
it is the simplest way to express what you want to do.  Being Pythonic
is not about using exotic features to scrunch your code down to a cool
one-liner.  It is about expressing your intentions in a simple, direct
way.  Sometimes comprehensions, generators, etc. help.  Sometimes they
only obfuscate.

That said, the *most* Pythonic way to do something is to find the
existing library that already does it.  Check out the Image.point()
function in the PIL documentation.  You may not need to convert the
image to a list at all.

- Roger



More information about the Python-list mailing list