Possible to fake object type?

Michael 'Mickey' Lauer mickey at tm.informatik.uni-frankfurt.de
Sat Mar 2 10:18:53 EST 2002


Chris Liechti <cliechti at gmx.net> wrote:
> Michael 'Mickey' Lauer <mickey at tm.informatik.uni-frankfurt.de> wrote 
> in
> news:3c80e76b at nntp.server.uni-frankfurt.de: 
>> So: Is it possible to fake the type of a class or
>> is it possible to magically override the method call "bouncing"
>> to the base class ?
> 
> you can allways call the methods of on e of the supperclasses by
> using:
> 
> Baseclass.method(self, args, ...)
> 
> it's the same you do in __init__ to initilaize base classes:
> 
> class Dockable(gtk.HandleBox):
>        def __init__(self):
>                gtk.HandleBox.__init__(self)
> 
>        def dosomething(self, arg):
>                print "calling dosomething...",
>                result = gtk.HandleBox.dosomething(self, arg)
>                print "result = %r" % result
>                return result

Yeah, sure, but I'd have to do this for every single
function - which is not quite the elegant solution
I aimed to come up with by using the getattr magic.

Yours,

:M:




More information about the Python-list mailing list