[Python-ideas] More power in list comprehensions with the 'as' keyword
cvrebert at gmail.com
Thu Aug 28 01:29:52 CEST 2008
On Wed, Aug 27, 2008 at 4:17 PM, Terry Reedy <tjreedy at udel.edu> wrote:
> Tarek Ziadé wrote:
>> [transform(e) as transformed for e in seq if some_test(transformed)]
>> In my use case I would simply have to write;:
>> [l.strip() as stripped for l in text.split('\n') if stripped != '']
>> Which seems to me clear and concise.
> -1 For me it is backward and confusing, whereas
> lines = 
> for l in test:
> l = l.strip()
> if l: lines.append(l)
> is clear as could be.
> To me, the drive to replace all for loops with list comps is mis-directed.
> There is no end to the clauses people could propose to add: while, when,
> whatever, until, unless. mapped_to, transformed_by, and so on. The result
> would soon by something quite different from Python as we know it.
Indeed, probably something approaching Common Lisp's overcomplicated
Follow the path of the Iguana...
> Python-ideas mailing list
> Python-ideas at python.org
More information about the Python-ideas