try:
    del i
except NameException:
    pass
for i in iterable:
    do_something(i)
try:
    del i
except NameException:
    do_something_else()
Idiomatic way of taking action on attempt to loop over an empty iterable