i wrote this code
--
class Person(object):
    instancesCount = 0
    def __init__(self, title=""):
        Person.instancesCount += 1
        self.id = "tempst"
    def testprint(self):
        print "blah blah"
    def __getattribute__(self, name):
        print "in get attribute"

a = Person()
a.testprint()
print a.id
-----
but i am getting this error
----
in get attribute
Traceback (most recent call last):
  File "trapmethodcall1.py", line 15, in <module>
    a.testprint()
TypeError: 'NoneType' object is not callable
------
why is it so? __getattribute__ is called whenever an attribute or method is
called, rt? or if i set __getattribute__ , i cannot have methods in class?

actually my aim is to trap all method calls and keep a counter which is
update whenever method called or returned. how should i go about it?
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to