def __getattr__(self, item):
try:<EOL><INDENT>if self.field_attr_on:<EOL><INDENT>if item == self.key_name:<EOL><INDENT>return self.key<EOL><DEDENT>return self._data[item]<EOL><DEDENT><DEDENT>except KeyError:<EOL><INDENT>if item in self.fields:<EOL><INDENT>return None<EOL><DEDENT><DEDENT>raise AttributeError(<EOL>"<STR_LIT>" % (<EOL>self.__class__.__name__, item))<EOL>
magic python method -- returns fields as an attribute of the object.
This is off by default.
You can enable it by setting `field_attr_on = True` on
your struct.

Then you can access data like so:

.. code-block:: python

    user = User('1')
    assert(user.name == 'bill')

:param item: str
:return: mixed