Если вы посмотрите на zope.interface.interfaces
module, вы обнаружите, что класс Interface
имеет IInterface
interface definition! Это документы метод names
следующим образом:
def names(all=False):
"""Get the interface attribute names
Return a sequence of the names of the attributes, including
methods, included in the interface definition.
Normally, only directly defined attributes are included. If
a true positional or keyword argument is given, then
attributes defined by base classes will be included.
"""
Чтобы таким образом расширить на вашем примере:
>>> from zope.interface import Interface, Attribute
>>> class IA(Interface):
... foo = Attribute("foo")
...
>>> IA.names()
['foo']
>>> class IB(IA):
... bar = Attribute("bar")
...
>>> IB.names()
['bar']
>>> IB.names(all=True)
['foo', 'bar']
Спасибо. По какой-то причине zope.interface на docs.zope.org ушел, и я не думал проверять подпись метода до тех пор, пока не разместил вопрос. – Ben