On Mar 19, 2:41 pm, Ben [EMAIL PROTECTED] wrote:
I have recently learned how list comprehension works and am finding it
extremely cool. I am worried, however, that I may be stuffing it into
places that it does not belong.
What's the most pythony way to do this:
even = []
for x in
Steve Holden [EMAIL PROTECTED] writes:
Alex Martelli wrote:
BJörn Lindqvist [EMAIL PROTECTED] wrote:
...
even2 = [(pos, col) for pos, col in iterimage(im, width, height, 2)]
list(iterimage(etc etc))
is surely a better way to express identical semantics. More
generally,
[x for x
Paddy [EMAIL PROTECTED] wrote:
...
I have found that I have gone too far when I used listcomps for their
sideeffects rather than wanting the list produced, for example the
I agree.
second listcomp below is an expression as statement I don't want the
list produced - just the effect on
On Mar 22, 4:56 am, [EMAIL PROTECTED] (Alex Martelli) wrote:
Paddy [EMAIL PROTECTED] wrote:
...
I have found that I have gone too far when I used listcomps for their
sideeffects rather than wanting the list produced, for example the
I agree.
second listcomp below is an expression
BJörn Lindqvist:
While they
may be faster, Psyco is great here. Also, if you have lots of 2d-loops
like for x in something: for y in something:, then it could be more
beautiful to separate the iteration from the task:
def iterimage(im, width, height, step = 1):
for y in range(0, height,
Alex Martelli wrote:
BJörn Lindqvist [EMAIL PROTECTED] wrote:
...
even2 = [(pos, col) for pos, col in iterimage(im, width, height, 2)]
list(iterimage(etc etc))
is surely a better way to express identical semantics. More generally,
[x for x in whatever] (whether x is a single name or
In article [EMAIL PROTECTED],
Alex Martelli [EMAIL PROTECTED] wrote:
list(iterimage(etc etc))
is surely a better way to express identical semantics. More generally,
[x for x in whatever] (whether x is a single name or gets peculiarly
unpacked and repacked like here) is a good example of
Aahz [EMAIL PROTECTED] wrote:
In article [EMAIL PROTECTED],
Alex Martelli [EMAIL PROTECTED] wrote:
list(iterimage(etc etc))
is surely a better way to express identical semantics. More generally,
[x for x in whatever] (whether x is a single name or gets peculiarly
unpacked and repacked
Ben [EMAIL PROTECTED] wrote:
I have recently learned how list comprehension works and am finding it
extremely cool. I am worried, however, that I may be stuffing it into
places that it does not belong.
What's the most pythony way to do this:
even = []
for x in range(0,width,2):
On Mar 19, 9:41 am, Ben [EMAIL PROTECTED] wrote:
even = []
for x in range(0,width,2):
for y in range(0,height,2):
color = im.getpixel((x,y))
even.append(((x,y), color))
versus list comprehension:
even2 = [((x,y), im.getpixel((x,y))) for x in range(0,width,2) for y
in
On 19 Mar 2007 07:41:59 -0700, Ben [EMAIL PROTECTED] wrote:
I have recently learned how list comprehension works and am finding it
extremely cool. I am worried, however, that I may be stuffing it into
places that it does not belong.
What's the most pythony way to do this:
even = []
for x
Ben [EMAIL PROTECTED] wrote:
What's the most pythony way to do this:
even = []
for x in range(0,width,2):
for y in range(0,height,2):
color = im.getpixel((x,y))
even.append(((x,y), color))
versus list comprehension:
even2 = [((x,y), im.getpixel((x,y))) for x in
On Mon, 19 Mar 2007 07:41:59 -0700, Ben wrote:
I have recently learned how list comprehension works and am finding it
extremely cool. I am worried, however, that I may be stuffing it into
places that it does not belong.
Others have suggested reasons why you might or might not want to use
BJörn Lindqvist [EMAIL PROTECTED] wrote:
...
even2 = [(pos, col) for pos, col in iterimage(im, width, height, 2)]
list(iterimage(etc etc))
is surely a better way to express identical semantics. More generally,
[x for x in whatever] (whether x is a single name or gets peculiarly
unpacked and
14 matches
Mail list logo