is list comprehension necessary?

rantingrick rantingrick at gmail.com
Wed Oct 27 06:28:21 CEST 2010


On Oct 26, 12:07 pm, Andre Alexander Bell <p... at andre-bell.de> wrote:
> Hello,
>
> I occasionally use LCs, if they seem useful. However, what I don't like
> about LCs is that they 'look-like' being a closed scope, while actually
> they are in the scope of there call. Example:
>
> >>> i = 5
> >>> l = [i**2 for i in range(3)]
> >>> i
>
> 2


I must admit you make a good point here however the only time that
will slip you up is when you first experienced the Python LC syntax.
After a few "hello world" LC's you'll begin to love and understand
them completely.



More information about the Python-list mailing list