This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Extend upon metaclass/type class documentation, here: zope.interface and usage of instances of classes as base classes
Type: enhancement Stage:
Components: Documentation Versions: Python 3.2
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: docs@python Nosy List: carsten.klein, docs@python, georg.brandl
Priority: normal Keywords:

Created on 2011-04-06 21:55 by carsten.klein, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (2)
msg133173 - (view) Author: Carsten Klein (carsten.klein) Date: 2011-04-06 21:55
In zope.interface, you have something the following construct:

class InterfaceBase:
  pass

Interface = InterfaceBase()



Using the above Interface as a derivation base for your own classes, will make that instance a type derived class:

class IFoo(Interface):
  pass

type(IFoo)
-> Interface

type(Interface)
-> type


I wonder why this behavior is not documented in the official documentation, or at least, I was unable to find it there...
msg133205 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2011-04-07 09:50
This doesn't work as you show.  What you probably meant was something like this:

class InterfaceBase(type):
    ...

Interface = InterfaceBase('Interface', (), {})

class IFoo(Interface):
    ...


which you can just as well do by using normal metaclass syntax.
History
Date User Action Args
2022-04-11 14:57:15adminsetgithub: 55998
2013-10-06 18:50:30georg.brandlsetstatus: open -> closed
resolution: works for me
2011-04-07 09:50:47georg.brandlsetnosy: + georg.brandl
messages: + msg133205
2011-04-06 21:55:20carsten.kleincreate