argument checking before getattr
Chris Liechti
cliechti at gmx.net
Sat Jan 12 12:27:11 EST 2002
More information about the Python-list mailing list
Sat Jan 12 12:27:11 EST 2002
- Previous message (by thread): argument checking before getattr
- Next message (by thread): argument checking before getattr
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Benjamin Tai <bt98 at doc.ic.ac.uk> wrote in news:3C406C31.D5ED90F6 at doc.ic.ac.uk: [snip] > Instead of doing (hiding) argument checking in the interface, now I am > hoping to do some type checking in Python. The following shows what I am > trying to achieve: > > class foo: > def foo_fun(self,args): > # do some checking on "args" > return getattr(self._base,"foo_fun") > > Instead of return the correct argument, it only returns a trace of the > following trace: > <built-in method foo_fun of foo object at 0x80ef820> > It doesn't work out. Why? because getattr gives you the function object in this case. use apply to call the function. or write self._base.foo_fun(args) -- Chris <cliechti at gmx.net>
- Previous message (by thread): argument checking before getattr
- Next message (by thread): argument checking before getattr
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list