Skip to content

Instantly share code, notes, and snippets.

@tritium21
Last active February 9, 2020 13:00
Show Gist options
  • Save tritium21/45b67d4d8b4703472d245cc714ad6469 to your computer and use it in GitHub Desktop.
Save tritium21/45b67d4d8b4703472d245cc714ad6469 to your computer and use it in GitHub Desktop.
magicians = "penn teller copperfield".split()
for magicians in magicians:
print(magicians)
# IS THE SAME AS
magicians = "penn teller copperfield".split()
_magicians_it = iter(magicians) # never enters the namespace
while True:
try:
magicians = next(_magicians_it)
print(magicians)
except StopIteration:
break
del _magicians_it # but uh, it never entered the namespace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment