empty classes as c structs?

Nick Coghlan ncoghlan at iinet.net.au
Sat Feb 5 04:15:36 EST 2005


Steven Bethard wrote:
> Yes -- help me rally behind my generic object PEP which proposes a Bunch 
> type (probably to be renamed) for the Python standard lib. =)

Did you see the suggestion of 'namespace' as a name? Given that the idea is to 
get access to the contents using the standard Python syntax for accessing module 
and class namespaces, it seems to make sense.

Michael Spencer also posted an interesting idea recently about setting up a view 
of an existing dictionary, rather than as a separate object:

class attr_view(object):
   def __init__(self, data):
     object.__setattr__(self, "_data", data)
   def __getattr__(self, attrname):
     return self._data[attrname]
   def __setattr__(self, attrname, value):
     self._data[attrname] = value

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at email.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.skystorm.net



More information about the Python-list mailing list