mixin helper class for unknown attribute access?
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

mixin helper class for unknown attribute access?

From: Alex Hunsley <lard@tardis.ed.ac.molar.uk>
Date: Mon Oct 31 2005 - 11:39:40 CET

I know that I can catch access to unknown attributes with code something
like the following:

class example:
      def __getattr__(self, name):
          if name == 'age':
              return __age
          else:
              raise AttributeError

but is there an existing mixin helper class in Python (or one someone
has written) already that will assist with this? (Just not wanting to
reinvent the wheel....)
Received on Mon Nov 21 01:07:32 2005