Last active
January 3, 2016 16:39
-
-
Save akaptur/8491168 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 Thing(object): | |
... def __init__(self, name, description): | |
... self.name = name | |
... self.desc = description | |
... | |
>>> b = Thing('box', 'empty') | |
>>> c = Thing('cat', 'fuzzy') | |
>>> collection = {'box': b, 'cat' : c} | |
>>> collection['box'] | |
<__main__.Thing object at 0x1073a2150> | |
>>> print b | |
<__main__.Thing object at 0x1073a2150> | |
>>> b | |
<__main__.Thing object at 0x1073a2150> | |
>>> b.name | |
'box' | |
>>> b.desc | |
'empty' | |
>>> collection['box'].name | |
'box' | |
>>> collection['box'].desc | |
'empty' | |
>>> collection['box'] is b | |
True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment