Created
February 26, 2018 19:15
-
-
Save ktl014/5c8d53faab18740ad8d6ccd1e55f9cc3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Library(object): | |
... def __init__(self): | |
... self.books = { 'title' : object, 'title2' : object, 'title3' : object, } | |
... def __getitem__(self, i): | |
... return self.books[i] | |
... def __iter__(self): | |
... return self.books.itervalues() | |
... | |
>>> library = Library() | |
>>> library['title'] | |
<type 'object'> | |
>>> for book in library: | |
... print book | |
... | |
<type 'object'> | |
<type 'object'> | |
<type 'object'> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment