This was inspired by Raymond Hettinger's presentation Transforming Code into Beautiful, Idiomatic Python.

Thank you Raymond.


In [1]:
from functools import partial

In [2]:
for foo in iter(partial(input), 'quit'):
    print('in loop:', foo)
    
print('after loop:', foo)


hello
in loop: hello
world
in loop: world
quit
after loop: world