Determining the metaclass
Carl Banks
pavlovevidence at gmail.com
Sat Aug 29 20:31:19 EDT 2009
On Aug 29, 5:12 pm, casebash <walkr... at gmail.com> wrote:
> Hi all,
>
> I cannot determine if a class is an instance of a particular
> metaclass. Here is my best attempt
>
> >>> class tmp(type):
>
> ... pass
> ...>>> def c(metaclass=tmp):
>
> ... pass
> ...>>> isinstance(c, tmp)
> False
> >>> isinstance(c.__class__, tmp)
>
> False
>
> Can anyone explain why this fails?
You're gonna kick yourself.
It's because you used "def" and not "class" to define c. If you'd
used "class" then then first test would have worked.
Carl Banks
More information about the Python-list
mailing list