Class that defines method __getattribute__ and __getattr__ : Attribute : Class PYTHON TUTORIALS


PYTHON TUTORIALS » Class » Attribute »

 

Class that defines method __getattribute__ and __getattr__


class DemonstrateAccessobject ):
   def __init__self ):
      self.value = 1
      
   def __getattribute__self, name ):
      print "__getattribute__ executing..."
      print "tClient attempt to access attribute:", name

      return object.__getattribute__self, name )

   def __getattr__self, name ):
      print "__getattr__ executing..."
      print "tClient attempt to access non-existent attribute:", name

      raise AttributeError, "Object has no attribute %s" % name



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Class
» Attribute