Popular recipes tagged "keys" but not "pyqt"http://code.activestate.com/recipes/tags/keys-pyqt/2011-05-26T20:15:16-07:00ActiveState Code RecipesDictionary Who's Keys Act Like Attributes As Well (Python) 2011-05-26T20:15:16-07:00Sunjay Varmahttp://code.activestate.com/recipes/users/4174115/http://code.activestate.com/recipes/577590-dictionary-whos-keys-act-like-attributes-as-well/ <p style="color: grey"> Python recipe 577590 by <a href="/recipes/users/4174115/">Sunjay Varma</a> (<a href="/recipes/tags/attribute/">attribute</a>, <a href="/recipes/tags/dict/">dict</a>, <a href="/recipes/tags/keys/">keys</a>). </p> <p>Think of this as a JavaScript object. In JavaScript, the objects can be referenced by indexing (e.g. d[name]) or by directly using the dot (.) operator (e.g. d.name).</p> <p>This is the same concept. </p> <p><strong>Note to Python 2.4 Users:</strong> You will need to change the "except KeyError as e:" line to "except KeyError, (e):".</p>