__getattr__ and functions that don't exist

bruno de chez modulix en face bruno at modulix.org
Fri May 26 13:16:14 CEST 2006

class Parrot(object):
    class _dummy(object):
        def __init__(self, obj, name):
            self.name = name
            self.obj = obj

        def __call__(self, *args, **kw):
            print "dummy %s for %s" % (self.name, self.obj)
            print "called with %s - %s" % (str(args), str(kw))

    def __getattr__(self, name):
        return self._dummy(self, name)

More information about the Python-list mailing list