Skip to content

Instantly share code, notes, and snippets.

@akaptur
Last active January 3, 2016 16:39
Show Gist options
  • Save akaptur/8491168 to your computer and use it in GitHub Desktop.
Save akaptur/8491168 to your computer and use it in GitHub Desktop.
>>> 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