[Python-ideas] "While" suggestion
Roman Susi
rnd at onego.ru
Tue Jul 29 12:15:40 CEST 2008
hi!
Jacob Rus wrote:
> Andrew Akira Toulouse wrote:
...
> Personally, I’d rather have this broken up than in one gigantic line
> that looks like:
>
> result = [int(line) for line in f if evenP(int(line))
> until int(line) == 0 with open(filename) as f]
I have not followed the thread, but the line above looks cool and
terrible at the same time.
I can't think what other operator can be squeezed into expression, maybe
try-except, eh?
result = [int(line) for line in f try if evenP(int(line))
until int(line) == 0 except ValueError("blabla")
with open(filename) as f]
I am not sure if this kind of SQLness should enter Python syntax at all...
Regards,
Roman
>
> As for:
>
>> tokenchecks = [token for regex,token in match_tok until
>> regex.match(s)] return tokenchecks[-1]
>
> This is much more readably expressed as:
>
> for regexp, token in match_tok:
> if regexp.match(s):
> return token
>
>
> Cheers,
> Jacob Rus
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>
> !DSPAM:488e7c4d23202007710671!
>
More information about the Python-ideas
mailing list