empty clause of for loops

Sven R. Kunze srkunze at mail.de
Wed Mar 16 06:36:09 EDT 2016


On 16.03.2016 11:28, Joaquin Alzola wrote:
> If len(my_iterable) is not 0:
>      for x in my_iterable:
>          # do
> else:
>       # do something else

I am sorry, I should have been more precise here.

my_iterable is an iterator that's exhausted after a complete iteration 
and cannot be restored.
It's furthermore too large to fit into memory completely.

Best,
Sven



More information about the Python-list mailing list