Created
November 1, 2019 02:27
-
-
Save dhilst/d7f4b0f9624c746bc238c33fad511949 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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