[Python-ideas] Control Flow - Never Executed Loop Body
Vito De Tullio
vito.detullio at gmail.com
Sun Mar 20 19:23:37 EDT 2016
Andrew Barnert via Python-ideas wrote:
> More generally, I think if this feature were to be added, "empty" is a
> reasonable name. The idiomatic way to write it today is something like:
>
> elem = empty = object()
> for elem in seq:
> do_stuff(elem)
> if elem is empty:
> do_empty_seq_stuff()
>
> So you're basically looking for syntactic sugar that abbreviated "if ...
> is empty:", right?
Maybe I'm missing something, but shoulnd't be like
if seq:
for elem in seq:
do_stuff(elem)
else:
do_empty_seq_stuff()
a trivial code handling an empty list?
--
By ZeD
More information about the Python-ideas
mailing list