-
-
Save stephengruppetta/795a0c5d3395f9bf81fef655d85650f1 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 AnotherIterable: | |
def __init__(self, iterable): | |
self.values = iterable | |
def __getitem__(self, item): | |
print( | |
f"AnotherIterable.__getitem__() has just " | |
f"been called with argument {item}" | |
) | |
return self.values[item] | |
my_iterable = AnotherIterable([2, 4, 6, 8]) | |
print("Ready to start the 'for' loop…\n") | |
for item in my_iterable: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment