Unexpected __metaclass__ method behavior
Bruno Desthuilliers
bdesth.quelquechose at free.quelquepart.fr
Sun Jan 6 13:44:02 EST 2008
anne.nospam01 at wangnick.de a écrit :
> Well, you see, I have some database functions that deal with "things"
> which are either classes or instances thereof. I though polymorphism
> would be a nice way to handle them identically, like:
>
> def do(thing): thing.Foo()
> do(t)
> do(Test)
>
> But never mind, I now understand that Test.__dict__ can contain only
> one entry for 'Foo', and that this must be matched.
You may want to have a look at FormEncode's "declarative" API, with
particular attention to the 'classinstancemethod' stuff.
More information about the Python-list
mailing list