__getattr__ demo : Class getattr : Class PYTHON examples


PYTHON examples » Class » Class getattr »

 

__getattr__ demo


__getattr__ demo


class empty:
     def __getattr__(self, attrname):
         if attrname == "age":
             return 41
         else:
             raise AttributeError, attrname

X = empty()
print X.age

           
       



    Related Scripts with Example Source Code in same category :

Leave a Comment / Note


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


PYTHON examples

 Navioo Class
» Class getattr