Python Standard Library Interfaces¶
The zope.interface.common
package provides interfaces for objects
distributed as part of the Python standard library. Importing these
modules (usually) has the effect of making the standard library objects
implement the correct interface.
zope.interface.common.interface¶
Interfaces for standard python exceptions
zope.interface.common.idatetime¶
Datetime interfaces.
This module is called idatetime because if it were called datetime the import of the real datetime would fail.
zope.interface.common.collections¶
Interface definitions paralleling the abstract base classes defined in
collections.abc
.
After this module is imported, the standard library types will declare
that they implement the appropriate interface. While most standard
library types will properly implement that interface (that
is, verifyObject(ISequence, list()))
will pass, for example), a few might not:
memoryview
doesn’t feature all the defined methods ofISequence
such ascount
; it is still declared to provideISequence
though.
collections.deque.pop
doesn’t accept theindex
argument ofcollections.abc.MutableSequence.pop
range.index
does not accept thestart
andstop
arguments.
New in version 5.0.0.
zope.interface.common.numbers¶
Interface definitions paralleling the abstract base classes defined in
numbers
.
After this module is imported, the standard library types will declare that they implement the appropriate interface.
New in version 5.0.0.
zope.interface.common.builtins¶
Interface definitions for builtin types.
After this module is imported, the standard library types will declare that they implement the appropriate interface.
New in version 5.0.0.
zope.interface.common.io¶
Interface definitions paralleling the abstract base classes defined in
io
.
After this module is imported, the standard library types will declare that they implement the appropriate interface.
New in version 5.0.0.
zope.interface.common.mapping¶
Mapping Interfaces.
Importing this module does not mark any standard classes as implementing any of these interfaces.
While this module is not deprecated, new code should generally use
zope.interface.common.collections
, specifically
IMapping
and
IMutableMapping
. This
module is occasionally useful for its extremely fine grained breakdown
of interfaces.
The standard library dict
and collections.UserDict
implement IMutableMapping
, but do not implement any of the
interfaces in this module.
zope.interface.common.sequence¶
Sequence Interfaces
Importing this module does not mark any standard classes as implementing any of these interfaces.
While this module is not deprecated, new code should generally use
zope.interface.common.collections
, specifically
ISequence
and
IMutableSequence
. This
module is occasionally useful for its fine-grained breakdown of interfaces.
The standard library list
, tuple
and
collections.UserList
, among others, implement ISequence
or IMutableSequence
but do not implement any of the interfaces
in this module.