[Python-Dev] Adding a conditional expression in Py3.0
Reinhold Birkenfeld
reinhold-birkenfeld-nospam at wolke7.net
Wed Sep 21 09:17:23 CEST 2005
Jason Orendorff wrote:
> Honestly, I think I would prefer this syntax. Examples from real
> code, before and after:
>
> lines = [line for line in pr.block.body
> if line.logical_line.strip() != '']
> lines = [for line in pr.block.body:
> if line.logical_line.strip() != '':
> line]
>
> row.values = \
> [line[col.start:col.end].strip() for col in columns]
> row.values = \
> [for col in columns: line[col.start:col.end].rstrip()]
>
> return [p for p in self.listdir(pattern) if p.isdir()]
> return [for p in self.listdir(pattern): if p.isdir(): p]
-1. Too much similarity with the for/if statement. People would say
"why can we put a for statement in brackets but not a try statement".
Reinhold
--
Mail address is perfectly valid!
More information about the Python-Dev
mailing list