diff options
Diffstat (limited to 'src/zope/interface/common')
| -rw-r--r-- | src/zope/interface/common/mapping.py | 33 | ||||
| -rw-r--r-- | src/zope/interface/common/sequence.py | 34 |
2 files changed, 39 insertions, 28 deletions
diff --git a/src/zope/interface/common/mapping.py b/src/zope/interface/common/mapping.py index 1c5661a..a005aed 100644 --- a/src/zope/interface/common/mapping.py +++ b/src/zope/interface/common/mapping.py @@ -17,6 +17,7 @@ Importing this module does *not* mark any standard classes as implementing any of these interfaces. """ from zope.interface import Interface +from zope.interface._compat import PYTHON2 as PY2 class IItemMapping(Interface): """Simplest readable mapping object @@ -89,14 +90,15 @@ class IIterableMapping(IEnumerableMapping): without copying. """ - def iterkeys(): - "iterate over keys; equivalent to ``__iter__``" + if PY2: + def iterkeys(): + "iterate over keys; equivalent to ``__iter__``" - def itervalues(): - "iterate over values" + def itervalues(): + "iterate over values" - def iteritems(): - "iterate over items" + def iteritems(): + "iterate over items" class IClonableMapping(Interface): """Something that can produce a copy of itself. @@ -115,8 +117,9 @@ class IExtendedReadMapping(IIterableMapping): in Python 3. """ - def has_key(key): - """Tell if a key exists in the mapping; equivalent to ``__contains__``""" + if PY2: + def has_key(key): + """Tell if a key exists in the mapping; equivalent to ``__contains__``""" class IExtendedWriteMapping(IWriteMapping): """Additional mutation methods. @@ -133,12 +136,16 @@ class IExtendedWriteMapping(IWriteMapping): def setdefault(key, default=None): "D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D" - def pop(k, *args): - """Remove specified key and return the corresponding value. + def pop(k, default=None): + """ + pop(k[,default]) -> value + + Remove specified key and return the corresponding value. - ``*args`` may contain a single default value, or may not be supplied. - If key is not found, default is returned if given, otherwise - `KeyError` is raised""" + If key is not found, *default* is returned if given, otherwise + `KeyError` is raised. Note that *default* must not be passed by + name. + """ def popitem(): """remove and return some (key, value) pair as a diff --git a/src/zope/interface/common/sequence.py b/src/zope/interface/common/sequence.py index 393918e..c36d615 100644 --- a/src/zope/interface/common/sequence.py +++ b/src/zope/interface/common/sequence.py @@ -19,6 +19,7 @@ as implementing any of these interfaces. __docformat__ = 'restructuredtext' from zope.interface import Interface +from zope.interface._compat import PYTHON2 as PY2 class IMinimalSequence(Interface): """Most basic sequence interface. @@ -79,13 +80,14 @@ class IReadSequence(IFiniteSequence): def __rmul__(n): """``x.__rmul__(n) <==> n * x``""" - def __getslice__(i, j): - """``x.__getslice__(i, j) <==> x[i:j]`` + if PY2: + def __getslice__(i, j): + """``x.__getslice__(i, j) <==> x[i:j]`` - Use of negative indices is not supported. + Use of negative indices is not supported. - Deprecated since Python 2.0 but still a part of `UserList`. - """ + Deprecated since Python 2.0 but still a part of `UserList`. + """ class IExtendedReadSequence(IReadSequence): """Full read interface for lists""" @@ -116,21 +118,23 @@ class IUniqueMemberWriteSequence(Interface): supports slice objects. """ - def __setslice__(i, j, other): - """``x.__setslice__(i, j, other) <==> x[i:j] = other`` + if PY2: + def __setslice__(i, j, other): + """``x.__setslice__(i, j, other) <==> x[i:j] = other`` - Use of negative indices is not supported. + Use of negative indices is not supported. - Deprecated since Python 2.0 but still a part of `UserList`. - """ + Deprecated since Python 2.0 but still a part of `UserList`. + """ - def __delslice__(i, j): - """``x.__delslice__(i, j) <==> del x[i:j]`` + def __delslice__(i, j): + """``x.__delslice__(i, j) <==> del x[i:j]`` - Use of negative indices is not supported. + Use of negative indices is not supported. + + Deprecated since Python 2.0 but still a part of `UserList`. + """ - Deprecated since Python 2.0 but still a part of `UserList`. - """ def __iadd__(y): """``x.__iadd__(y) <==> x += y``""" |
