title: Python Object as Dictionary Value
body: <p>So I have the following code in which the value of a dictionary is an object, and the key to that object is an item in the object as such:</p>
  
  <pre><code>class MyObject():
      def getName(self):
         return self.name
  
      def getValue(self):
         return self.value
  
      def __init__(self,name, value):
         self.name = name
         self.value = value
  
  
  dict = {}
  object = MyObject('foo', 2) //foo is the name, 2 is the value
  dict[object.getName()] = object
  </code></pre>
  
  <p>However I cannot access the object like so:</p>
  
  <pre><code>&gt;&gt;&gt;print dict['foo'].getValue()
  &lt;bound method object.getValue of &lt;__main__.object instance at 0xFOOBAR000 &gt;&gt;
  </code></pre>
  
  <p>Is there a way I can access the object in this manner?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I don't know why but my code finally decided to start working, so for anyone haveing similar issues the above code is valid and should work. My current version of Python is 2.7.3</p>