for statement on empty iterable

james_027 cai.haibin at gmail.com
Wed Aug 22 01:28:27 EDT 2007


hi,

I need to do some for loop on iterables which could be empty
sometimes, for example

a_list = []

for i in a_list:
 #do something

is this safe? or should I put a if statement to test it first?

Thanks
james




More information about the Python-list mailing list