Re: list comprehension
- From: "Eric S. Johansson" <esj@xxxxxxxxxx>
- Date: Fri, 30 Jun 2006 08:11:03 -0400
tac-tics wrote:
a wrote:can someone tell me how to use them
thanks
sigh...
You do a google on them:
http://docs.python.org/tut/node7.html#SECTION007140000000000000000
thank you for the reminder. But after reading it, I was left with a question. Why the new syntax for what appears to be nothing more than a different way of expressing nested for loops? at first I tried rearranging the one of the examples from the previously referenced document to clarify (in my mind) what was going on:
[x*y
for x in vec1
for y in vec2
]
then when I tried to rewrite it as a nested for loop, that's when I realized list comprehensions is a method of returning the calculation in the interior of a for loop as an assignment without requiring aggregation of results in a temporary variable.
so a double thank you to you because you've clarified something that has been a mystery to me for awhile.
now if I could find someone to explain distutils and eggs so that I understand that as well... ;-) Heck, I would even settle for a wizard tool generating the first approximation for me.
---eric
.
- References:
- list comprehension
- From: a
- Re: list comprehension
- From: tac-tics
- list comprehension
- Prev by Date: Re: logging error with RotatingFileHandler
- Next by Date: Re: conecting with a MsAcces DB by dao
- Previous by thread: Re: list comprehension
- Next by thread: XMLLIB
- Index(es):
Relevant Pages
|