zope.interface.interfaces
モジュールを見ると、Interface
クラスにIInterface
インターフェース定義があることがわかります。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']