Re: Newbie question about tuples and list comprehensions



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
.



Relevant Pages

  • Re: Threading, Loops, and Direct3D
    ... I appologise for the vagueness of the last, post, but my code is very ... complicated and by the time I'd gotten around to producing the simplest ... Moving it to a higher context (out of the while loop) fixed it. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Numeric one-way hash function
    ... >> The simplest way to ensure that the bar codes are ... > don't understand your algorithm. ... end loop ...
    (sci.crypt)
  • Re: Modulo exponentiation 2 bits at a time.
    ... I'm looking for reference on a modulo exponentiation algorithm that ... algorithm that just use 1 bit for each loop. ... The loop in the simplest algo is something like: ... Add 'window' to your google search. ...
    (sci.math)
  • Re: how to write a C-style for loop?
    ... How would that go in Python, in the simplest and most efficient way? ... practice in just about any programming language that has for loops. ... earth would any sensible programmer want to manage the loop variable by ...
    (comp.lang.python)
  • Re: question about tasks, multithreading and multi-cpu machines
    ... Maciej Sobczak wrote: ... the simplest case you do this: ... for I in Vector'Range loop ... "The time has come to act, and act fast. ...
    (comp.lang.ada)

Loading