Skip to content

Instantly share code, notes, and snippets.

@dhilst
Created November 1, 2019 02:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhilst/d7f4b0f9624c746bc238c33fad511949 to your computer and use it in GitHub Desktop.
Save dhilst/d7f4b0f9624c746bc238c33fad511949 to your computer and use it in GitHub Desktop.
class HasIter:
def __iter__(self):
return iter(range(10))
def foo(value):
try:
for i in value:
print(i)
except TypeError:
print(value)
foo(1)
print()
foo([1,2,3])
print()
foo(HasIter())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment