Python Standard Library Interfaces¶
The zope.interface.common
package provides interfaces for objects
distributed as part of the Python standard library. Importing these
modules has the effect of making the standard library objects
implement the correct interface.
zope.interface.common.interfaces
¶
Interfaces for standard python exceptions
-
interface
zope.interface.common.interfaces.
IStandardError
[source]¶ Extends:
zope.interface.common.interfaces.IException
Interface for
StandardError
(Python 2 only.)
-
interface
zope.interface.common.interfaces.
IWarning
[source]¶ Extends:
zope.interface.common.interfaces.IException
Interface for
Warning
-
interface
zope.interface.common.interfaces.
ISyntaxError
[source]¶ Extends:
zope.interface.common.interfaces.IStandardError
Interface for
SyntaxError
-
interface
zope.interface.common.interfaces.
ILookupError
[source]¶ Extends:
zope.interface.common.interfaces.IStandardError
Interface for
LookupError
-
interface
zope.interface.common.interfaces.
IValueError
[source]¶ Extends:
zope.interface.common.interfaces.IStandardError
Interface for
ValueError
-
interface
zope.interface.common.interfaces.
IRuntimeError
[source]¶ Extends:
zope.interface.common.interfaces.IStandardError
Interface for
RuntimeError
-
interface
zope.interface.common.interfaces.
IArithmeticError
[source]¶ Extends:
zope.interface.common.interfaces.IStandardError
Interface for
ArithmeticError
-
interface
zope.interface.common.interfaces.
IAssertionError
[source]¶ Extends:
zope.interface.common.interfaces.IStandardError
Interface for
AssertionError
-
interface
zope.interface.common.interfaces.
IAttributeError
[source]¶ Extends:
zope.interface.common.interfaces.IStandardError
Interface for
AttributeError
-
interface
zope.interface.common.interfaces.
IDeprecationWarning
[source]¶ Extends:
zope.interface.common.interfaces.IWarning
Interface for
DeprecationWarning
-
interface
zope.interface.common.interfaces.
IEOFError
[source]¶ Extends:
zope.interface.common.interfaces.IStandardError
Interface for
EOFError
-
interface
zope.interface.common.interfaces.
IEnvironmentError
[source]¶ Extends:
zope.interface.common.interfaces.IStandardError
Interface for
EnvironmentError
-
interface
zope.interface.common.interfaces.
IFloatingPointError
[source]¶ Extends:
zope.interface.common.interfaces.IArithmeticError
Interface for
FloatingPointError
-
interface
zope.interface.common.interfaces.
IIOError
[source]¶ Extends:
zope.interface.common.interfaces.IEnvironmentError
Interface for
IOError
-
interface
zope.interface.common.interfaces.
IImportError
[source]¶ Extends:
zope.interface.common.interfaces.IStandardError
Interface for
ImportError
-
interface
zope.interface.common.interfaces.
IIndentationError
[source]¶ Extends:
zope.interface.common.interfaces.ISyntaxError
Interface for
IndentationError
-
interface
zope.interface.common.interfaces.
IIndexError
[source]¶ Extends:
zope.interface.common.interfaces.ILookupError
Interface for
IndexError
-
interface
zope.interface.common.interfaces.
IKeyError
[source]¶ Extends:
zope.interface.common.interfaces.ILookupError
Interface for
KeyError
-
interface
zope.interface.common.interfaces.
IKeyboardInterrupt
[source]¶ Extends:
zope.interface.common.interfaces.IStandardError
Interface for
KeyboardInterrupt
-
interface
zope.interface.common.interfaces.
IMemoryError
[source]¶ Extends:
zope.interface.common.interfaces.IStandardError
Interface for
MemoryError
-
interface
zope.interface.common.interfaces.
INameError
[source]¶ Extends:
zope.interface.common.interfaces.IStandardError
Interface for
NameError
-
interface
zope.interface.common.interfaces.
INotImplementedError
[source]¶ Extends:
zope.interface.common.interfaces.IRuntimeError
Interface for
NotImplementedError
-
interface
zope.interface.common.interfaces.
IOSError
[source]¶ Extends:
zope.interface.common.interfaces.IEnvironmentError
Interface for
OSError
-
interface
zope.interface.common.interfaces.
IOverflowError
[source]¶ Extends:
zope.interface.common.interfaces.IArithmeticError
Interface for
ArithmeticError
-
interface
zope.interface.common.interfaces.
IOverflowWarning
[source]¶ Extends:
zope.interface.common.interfaces.IWarning
Deprecated, no standard class implements this.
This was the interface for
OverflowWarning
prior to Python 2.5, but that class was removed for all versions after that.
-
interface
zope.interface.common.interfaces.
IReferenceError
[source]¶ Extends:
zope.interface.common.interfaces.IStandardError
Interface for
ReferenceError
-
interface
zope.interface.common.interfaces.
IRuntimeWarning
[source]¶ Extends:
zope.interface.common.interfaces.IWarning
Interface for
RuntimeWarning
-
interface
zope.interface.common.interfaces.
IStopIteration
[source]¶ Extends:
zope.interface.common.interfaces.IException
Interface for
StopIteration
-
interface
zope.interface.common.interfaces.
ISyntaxWarning
[source]¶ Extends:
zope.interface.common.interfaces.IWarning
Interface for
SyntaxWarning
-
interface
zope.interface.common.interfaces.
ISystemError
[source]¶ Extends:
zope.interface.common.interfaces.IStandardError
Interface for
SystemError
-
interface
zope.interface.common.interfaces.
ISystemExit
[source]¶ Extends:
zope.interface.common.interfaces.IException
Interface for
SystemExit
-
interface
zope.interface.common.interfaces.
ITabError
[source]¶ Extends:
zope.interface.common.interfaces.IIndentationError
Interface for
TabError
-
interface
zope.interface.common.interfaces.
ITypeError
[source]¶ Extends:
zope.interface.common.interfaces.IStandardError
Interface for
TypeError
-
interface
zope.interface.common.interfaces.
IUnboundLocalError
[source]¶ Extends:
zope.interface.common.interfaces.INameError
Interface for
UnboundLocalError
-
interface
zope.interface.common.interfaces.
IUnicodeError
[source]¶ Extends:
zope.interface.common.interfaces.IValueError
Interface for
UnicodeError
-
interface
zope.interface.common.interfaces.
IUserWarning
[source]¶ Extends:
zope.interface.common.interfaces.IWarning
Interface for
UserWarning
-
interface
zope.interface.common.interfaces.
IZeroDivisionError
[source]¶ Extends:
zope.interface.common.interfaces.IArithmeticError
Interface for
ZeroDivisionError
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.
-
interface
zope.interface.common.idatetime.
ITimeDeltaClass
[source]¶ This is the timedelta class interface.
This is symbolic; this module does not make
datetime.timedelta
provide this interface.-
min
¶ The most negative timedelta object
-
max
¶ The most positive timedelta object
-
resolution
¶ The smallest difference between non-equal timedelta objects
-
-
interface
zope.interface.common.idatetime.
ITimeDelta
[source]¶ Extends:
zope.interface.common.idatetime.ITimeDeltaClass
Represent the difference between two datetime objects.
Implemented by
datetime.timedelta
.Supported operators:
- add, subtract timedelta
- unary plus, minus, abs
- compare to timedelta
- multiply, divide by int/long
In addition,
datetime
supports subtraction of twodatetime
objects returning atimedelta
, and addition or subtraction of adatetime
and atimedelta
giving adatetime
.Representation: (days, seconds, microseconds).
-
days
¶ Days between -999999999 and 999999999 inclusive
-
seconds
¶ Seconds between 0 and 86399 inclusive
-
microseconds
¶ Microseconds between 0 and 999999 inclusive
-
interface
zope.interface.common.idatetime.
IDateClass
[source]¶ This is the date class interface.
This is symbolic; this module does not make
datetime.date
provide this interface.-
min
¶ The earliest representable date
-
max
¶ The latest representable date
-
resolution
¶ The smallest difference between non-equal date objects
-
today
()¶ Return the current local time.
This is equivalent to
date.fromtimestamp(time.time())
-
fromtimestamp
(timestamp)¶ Return the local date from a POSIX timestamp (like time.time())
This may raise
ValueError
, if the timestamp is out of the range of values supported by the platform Clocaltime()
function. It’s common for this to be restricted to years from 1970 through 2038. Note that on non-POSIX systems that include leap seconds in their notion of a timestamp, leap seconds are ignored byfromtimestamp
.
-
fromordinal
(ordinal)¶ Return the date corresponding to the proleptic Gregorian ordinal.
January 1 of year 1 has ordinal 1.
ValueError
is raised unless 1 <= ordinal <= date.max.toordinal().For any date d,
date.fromordinal(d.toordinal()) == d
.
-
-
interface
zope.interface.common.idatetime.
IDate
[source]¶ Extends:
zope.interface.common.idatetime.IDateClass
Represents a date (year, month and day) in an idealized calendar.
Implemented by
datetime.date
.Operators:
__repr__, __str__ __cmp__, __hash__ __add__, __radd__, __sub__ (add/radd only with timedelta arg)
-
year
¶ Between MINYEAR and MAXYEAR inclusive.
-
month
¶ Between 1 and 12 inclusive
-
day
¶ Between 1 and the number of days in the given month of the given year.
-
replace
(year, month, day)¶ Return a date with the same value.
Except for those members given new values by whichever keyword arguments are specified. For example, if
d == date(2002, 12, 31)
, thend.replace(day=26) == date(2000, 12, 26)
.
-
timetuple
()¶ Return a 9-element tuple of the form returned by
time.localtime
.The hours, minutes and seconds are 0, and the DST flag is -1.
d.timetuple()
is equivalent to(d.year, d.month, d.day, 0, 0, 0, d.weekday(), d.toordinal() - date(d.year, 1, 1).toordinal() + 1, -1)
-
toordinal
()¶ Return the proleptic Gregorian ordinal of the date
January 1 of year 1 has ordinal 1. For any date object d,
date.fromordinal(d.toordinal()) == d
.
-
weekday
()¶ Return the day of the week as an integer.
Monday is 0 and Sunday is 6. For example,
date(2002, 12, 4).weekday() == 2
, a Wednesday.See also
-
isoweekday
()¶ Return the day of the week as an integer.
Monday is 1 and Sunday is 7. For example, date(2002, 12, 4).isoweekday() == 3, a Wednesday.
See also
-
isocalendar
()¶ Return a 3-tuple, (ISO year, ISO week number, ISO weekday).
The ISO calendar is a widely used variant of the Gregorian calendar. See http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm for a good explanation.
The ISO year consists of 52 or 53 full weeks, and where a week starts on a Monday and ends on a Sunday. The first week of an ISO year is the first (Gregorian) calendar week of a year containing a Thursday. This is called week number 1, and the ISO year of that Thursday is the same as its Gregorian year.
For example, 2004 begins on a Thursday, so the first week of ISO year 2004 begins on Monday, 29 Dec 2003 and ends on Sunday, 4 Jan 2004, so that
date(2003, 12, 29).isocalendar() == (2004, 1, 1)
anddate(2004, 1, 4).isocalendar() == (2004, 1, 7)
.
-
isoformat
()¶ Return a string representing the date in ISO 8601 format.
This is ‘YYYY-MM-DD’. For example,
date(2002, 12, 4).isoformat() == '2002-12-04'
.
-
__str__
()¶ For a date d,
str(d)
is equivalent tod.isoformat()
.
-
ctime
()¶ Return a string representing the date.
For example date(2002, 12, 4).ctime() == ‘Wed Dec 4 00:00:00 2002’. d.ctime() is equivalent to time.ctime(time.mktime(d.timetuple())) on platforms where the native C ctime() function (which
time.ctime
invokes, but which date.ctime() does not invoke) conforms to the C standard.
-
strftime
(format)¶ Return a string representing the date.
Controlled by an explicit format string. Format codes referring to hours, minutes or seconds will see 0 values.
-
-
interface
zope.interface.common.idatetime.
IDateTimeClass
[source]¶ This is the datetime class interface.
This is symbolic; this module does not make
datetime.datetime
provide this interface.-
min
¶ The earliest representable datetime
-
max
¶ The latest representable datetime
-
resolution
¶ The smallest possible difference between non-equal datetime objects
-
today
()¶ Return the current local datetime, with tzinfo None.
This is equivalent to
datetime.fromtimestamp(time.time())
.See also
-
now
(tz=None)¶ Return the current local date and time.
If optional argument tz is None or not specified, this is like
today
, but, if possible, supplies more precision than can be gotten from going through atime.time
timestamp (for example, this may be possible on platforms supplying the Cgettimeofday()
function).Else tz must be an instance of a class tzinfo subclass, and the current date and time are converted to tz’s time zone. In this case the result is equivalent to tz.fromutc(datetime.utcnow().replace(tzinfo=tz)).
-
utcnow
()¶ Return the current UTC date and time, with tzinfo None.
This is like
now
, but returns the current UTC date and time, as a naive datetime object.See also
now
.
-
fromtimestamp
(timestamp, tz=None)¶ Return the local date and time corresponding to the POSIX timestamp.
Same as is returned by time.time(). If optional argument tz is None or not specified, the timestamp is converted to the platform’s local date and time, and the returned datetime object is naive.
Else tz must be an instance of a class tzinfo subclass, and the timestamp is converted to tz’s time zone. In this case the result is equivalent to
tz.fromutc(datetime.utcfromtimestamp(timestamp).replace(tzinfo=tz))
.fromtimestamp() may raise
ValueError
, if the timestamp is out of the range of values supported by the platform C localtime() or gmtime() functions. It’s common for this to be restricted to years in 1970 through 2038. Note that on non-POSIX systems that include leap seconds in their notion of a timestamp, leap seconds are ignored by fromtimestamp(), and then it’s possible to have two timestamps differing by a second that yield identical datetime objects.See also
-
utcfromtimestamp
(timestamp)¶ Return the UTC datetime from the POSIX timestamp with tzinfo None.
This may raise
ValueError
, if the timestamp is out of the range of values supported by the platform Cgmtime()
function. It’s common for this to be restricted to years in 1970 through 2038.See also
-
fromordinal
(ordinal)¶ Return the datetime from the proleptic Gregorian ordinal.
January 1 of year 1 has ordinal 1.
ValueError
is raised unless 1 <= ordinal <= datetime.max.toordinal(). The hour, minute, second and microsecond of the result are all 0, and tzinfo is None.
-
combine
(date, time)¶ Return a new datetime object.
Its date members are equal to the given date object’s, and whose time and tzinfo members are equal to the given time object’s. For any datetime object d,
d == datetime.combine(d.date(), d.timetz())
. If date is a datetime object, its time and tzinfo members are ignored.
-
-
interface
zope.interface.common.idatetime.
IDateTime
[source]¶ Extends:
zope.interface.common.idatetime.IDate
,zope.interface.common.idatetime.IDateTimeClass
Object contains all the information from a date object and a time object.
Implemented by
datetime.datetime
.-
year
¶ Year between MINYEAR and MAXYEAR inclusive
-
month
¶ Month between 1 and 12 inclusive
-
day
¶ Day between 1 and the number of days in the given month of the year
-
hour
¶ Hour in range(24)
-
minute
¶ Minute in range(60)
-
second
¶ Second in range(60)
-
microsecond
¶ Microsecond in range(1000000)
-
tzinfo
¶ The object passed as the tzinfo argument to the datetime constructor or None if none was passed
-
date
()¶ Return date object with same year, month and day.
-
time
()¶ Return time object with same hour, minute, second, microsecond.
tzinfo is None.
See also
Method
timetz()
.
-
timetz
()¶ Return time object with same hour, minute, second, microsecond, and tzinfo.
See also
Method
time()
.
-
replace
(year, month, day, hour, minute, second, microsecond, tzinfo)¶ Return a datetime with the same members, except for those members given new values by whichever keyword arguments are specified.
Note that
tzinfo=None
can be specified to create a naive datetime from an aware datetime with no conversion of date and time members.
-
astimezone
(tz)¶ Return a datetime object with new tzinfo member tz, adjusting the date and time members so the result is the same UTC time as self, but in tz’s local time.
tz must be an instance of a tzinfo subclass, and its utcoffset() and dst() methods must not return None. self must be aware (self.tzinfo must not be None, and self.utcoffset() must not return None).
If self.tzinfo is tz, self.astimezone(tz) is equal to self: no adjustment of date or time members is performed. Else the result is local time in time zone tz, representing the same UTC time as self:
after astz = dt.astimezone(tz), astz - astz.utcoffset()will usually have the same date and time members as dt - dt.utcoffset(). The discussion of class
datetime.tzinfo
explains the cases at Daylight Saving Time transition boundaries where this cannot be achieved (an issue only if tz models both standard and daylight time).If you merely want to attach a time zone object tz to a datetime dt without adjustment of date and time members, use
dt.replace(tzinfo=tz)
. If you merely want to remove the time zone object from an aware datetime dt without conversion of date and time members, usedt.replace(tzinfo=None)
.Note that the default
tzinfo.fromutc
method can be overridden in a tzinfo subclass to effect the result returned byastimezone
.
-
utcoffset
()¶ Return the timezone offset in minutes east of UTC (negative west of UTC).
-
dst
()¶ Return 0 if DST is not in effect, or the DST offset (in minutes eastward) if DST is in effect.
-
tzname
()¶ Return the timezone name.
-
timetuple
()¶ Return a 9-element tuple of the form returned by
time.localtime
.
-
utctimetuple
()¶ Return UTC time tuple compatilble with
time.gmtime
.
-
toordinal
()¶ Return the proleptic Gregorian ordinal of the date.
The same as self.date().toordinal().
-
weekday
()¶ Return the day of the week as an integer.
Monday is 0 and Sunday is 6. The same as self.date().weekday(). See also isoweekday().
-
isoweekday
()¶ Return the day of the week as an integer.
Monday is 1 and Sunday is 7. The same as self.date().isoweekday.
See also
-
isocalendar
()¶ Return a 3-tuple, (ISO year, ISO week number, ISO weekday).
The same as self.date().isocalendar().
-
isoformat
(sep='T')¶ Return a string representing the date and time in ISO 8601 format.
YYYY-MM-DDTHH:MM:SS.mmmmmm or YYYY-MM-DDTHH:MM:SS if microsecond is 0
If
utcoffset
does not return None, a 6-character string is appended, giving the UTC offset in (signed) hours and minutes:YYYY-MM-DDTHH:MM:SS.mmmmmm+HH:MM or YYYY-MM-DDTHH:MM:SS+HH:MM if microsecond is 0.
The optional argument sep (default ‘T’) is a one-character separator, placed between the date and time portions of the result.
-
__str__
()¶ For a datetime instance d,
str(d)
is equivalent tod.isoformat(' ')
.
-
ctime
()¶ Return a string representing the date and time.
datetime(2002, 12, 4, 20, 30, 40).ctime() == 'Wed Dec 4 20:30:40 2002'
.d.ctime()
is equivalent totime.ctime(time.mktime(d.timetuple()))
on platforms where the native Cctime()
function (whichtime.ctime
invokes, but whichdatetime.ctime
does not invoke) conforms to the C standard.
-
strftime
(format)¶ Return a string representing the date and time.
This is controlled by an explicit format string.
-
-
interface
zope.interface.common.idatetime.
ITimeClass
[source]¶ This is the time class interface.
This is symbolic; this module does not make
datetime.time
provide this interface.-
min
¶ The earliest representable time
-
max
¶ The latest representable time
-
resolution
¶ The smallest possible difference between non-equal time objects
-
-
interface
zope.interface.common.idatetime.
ITime
[source]¶ Extends:
zope.interface.common.idatetime.ITimeClass
Represent time with time zone.
Implemented by
datetime.time
.Operators:
__repr__, __str__ __cmp__, __hash__
-
hour
¶ Hour in range(24)
-
minute
¶ Minute in range(60)
-
second
¶ Second in range(60)
-
microsecond
¶ Microsecond in range(1000000)
-
tzinfo
¶ The object passed as the tzinfo argument to the time constructor or None if none was passed.
-
replace
(hour, minute, second, microsecond, tzinfo)¶ Return a time with the same value.
Except for those members given new values by whichever keyword arguments are specified. Note that tzinfo=None can be specified to create a naive time from an aware time, without conversion of the time members.
-
isoformat
()¶ Return a string representing the time in ISO 8601 format.
That is HH:MM:SS.mmmmmm or, if self.microsecond is 0, HH:MM:SS If utcoffset() does not return None, a 6-character string is appended, giving the UTC offset in (signed) hours and minutes: HH:MM:SS.mmmmmm+HH:MM or, if self.microsecond is 0, HH:MM:SS+HH:MM
-
__str__
()¶ For a time t, str(t) is equivalent to t.isoformat().
-
strftime
(format)¶ Return a string representing the time.
This is controlled by an explicit format string.
-
utcoffset
()¶ Return the timezone offset in minutes east of UTC (negative west of UTC).
If tzinfo is None, returns None, else returns self.tzinfo.utcoffset(None), and raises an exception if the latter doesn’t return None or a timedelta object representing a whole number of minutes with magnitude less than one day.
-
dst
()¶ Return 0 if DST is not in effect, or the DST offset (in minutes eastward) if DST is in effect.
If tzinfo is None, returns None, else returns self.tzinfo.dst(None), and raises an exception if the latter doesn’t return None, or a timedelta object representing a whole number of minutes with magnitude less than one day.
-
tzname
()¶ Return the timezone name.
If tzinfo is None, returns None, else returns self.tzinfo.tzname(None), or raises an exception if the latter doesn’t return None or a string object.
-
-
interface
zope.interface.common.idatetime.
ITZInfo
[source]¶ Time zone info class.
-
utcoffset
(dt)¶ Return offset of local time from UTC, in minutes east of UTC.
If local time is west of UTC, this should be negative. Note that this is intended to be the total offset from UTC; for example, if a tzinfo object represents both time zone and DST adjustments, utcoffset() should return their sum. If the UTC offset isn’t known, return None. Else the value returned must be a timedelta object specifying a whole number of minutes in the range -1439 to 1439 inclusive (1440 = 24*60; the magnitude of the offset must be less than one day).
-
dst
(dt)¶ Return the daylight saving time (DST) adjustment, in minutes east of UTC, or None if DST information isn’t known.
-
tzname
(dt)¶ Return the time zone name corresponding to the datetime object as a string.
-
fromutc
(dt)¶ Return an equivalent datetime in self’s local time.
-
zope.interface.common.mapping
¶
Mapping Interfaces.
Importing this module does not mark any standard classes as implementing any of these interfaces.
-
interface
zope.interface.common.mapping.
IItemMapping
[source]¶ Simplest readable mapping object
-
__getitem__
(key)¶ Get a value for a key
A
KeyError
is raised if there is no value for the key.
-
-
interface
zope.interface.common.mapping.
IReadMapping
[source]¶ Extends:
zope.interface.common.mapping.IItemMapping
Basic mapping interface
-
get
(key, default=None)¶ Get a value for a key
The default is returned if there is no value for the key.
-
__contains__
(key)¶ Tell if a key exists in the mapping.
-
-
interface
zope.interface.common.mapping.
IWriteMapping
[source]¶ Mapping methods for changing data
-
__delitem__
(key)¶ Delete a value from the mapping using the key.
-
__setitem__
(key, value)¶ Set a new item in the mapping.
-
-
interface
zope.interface.common.mapping.
IEnumerableMapping
[source]¶ Extends:
zope.interface.common.mapping.IReadMapping
Mapping objects whose items can be enumerated.
-
keys
()¶ Return the keys of the mapping object.
-
__iter__
()¶ Return an iterator for the keys of the mapping object.
-
values
()¶ Return the values of the mapping object.
-
items
()¶ Return the items of the mapping object.
-
__len__
()¶ Return the number of items.
-
-
interface
zope.interface.common.mapping.
IMapping
[source]¶ Extends:
zope.interface.common.mapping.IWriteMapping
,zope.interface.common.mapping.IEnumerableMapping
Simple mapping interface
-
interface
zope.interface.common.mapping.
IIterableMapping
[source]¶ Extends:
zope.interface.common.mapping.IEnumerableMapping
A mapping that has distinct methods for iterating without copying.
On Python 2, a
dict
has these methods, but on Python 3 the methods defined inIEnumerableMapping
already iterate without copying.-
iterkeys
()¶ iterate over keys; equivalent to
__iter__
-
itervalues
()¶ iterate over values
-
iteritems
()¶ iterate over items
-
-
interface
zope.interface.common.mapping.
IClonableMapping
[source]¶ Something that can produce a copy of itself.
This is available in
dict
.-
copy
()¶ return copy of dict
-
-
interface
zope.interface.common.mapping.
IExtendedReadMapping
[source]¶ Extends:
zope.interface.common.mapping.IIterableMapping
Something with a particular method equivalent to
__contains__
.On Python 2,
dict
provides this method, but it was removed in Python 3.-
has_key
(key)¶ Tell if a key exists in the mapping; equivalent to
__contains__
-
-
interface
zope.interface.common.mapping.
IExtendedWriteMapping
[source]¶ Extends:
zope.interface.common.mapping.IWriteMapping
Additional mutation methods.
These are all provided by
dict
.-
clear
()¶ delete all items
-
update
(d)¶ Update D from E: for k in E.keys(): D[k] = E[k]
-
setdefault
(key, default=None)¶ D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D
-
pop
(k, *args)¶ 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, otherwiseKeyError
is raised
-
popitem
()¶ remove and return some (key, value) pair as a 2-tuple; but raise KeyError if mapping is empty
-
-
interface
zope.interface.common.mapping.
IFullMapping
[source]¶ Extends:
zope.interface.common.mapping.IExtendedReadMapping
,zope.interface.common.mapping.IExtendedWriteMapping
,zope.interface.common.mapping.IClonableMapping
,zope.interface.common.mapping.IMapping
Full mapping interface
zope.interface.common.sequence
¶
Sequence Interfaces
Importing this module does not mark any standard classes as implementing any of these interfaces.
-
interface
zope.interface.common.sequence.
IMinimalSequence
[source]¶ Most basic sequence interface.
All sequences are iterable. This requires at least one of the following:
- a
__getitem__()
method that takes a single argument; integer values starting at 0 must be supported, andIndexError
should be raised for the first index for which there is no value, or - an
__iter__()
method that returns an iterator as defined in the Python documentation (http://docs.python.org/lib/typeiter.html).
-
__getitem__
(index)¶ x.__getitem__(index) <==> x[index]
Declaring this interface does not specify whether
__getitem__
supports slice objects.
- a
-
interface
zope.interface.common.sequence.
IReadSequence
[source]¶ Extends:
zope.interface.common.sequence.IFiniteSequence
read interface shared by tuple and list
-
__contains__
(item)¶ x.__contains__(item) <==> item in x
-
__lt__
(other)¶ x.__lt__(other) <==> x < other
-
__le__
(other)¶ x.__le__(other) <==> x <= other
-
__eq__
(other)¶ x.__eq__(other) <==> x == other
-
__ne__
(other)¶ x.__ne__(other) <==> x != other
-
__gt__
(other)¶ x.__gt__(other) <==> x > other
-
__ge__
(other)¶ x.__ge__(other) <==> x >= other
-
__add__
(other)¶ x.__add__(other) <==> x + other
-
__mul__
(n)¶ x.__mul__(n) <==> x * n
-
__rmul__
(n)¶ x.__rmul__(n) <==> n * x
-
__getslice__
(i, j)¶ x.__getslice__(i, j) <==> x[i:j]
Use of negative indices is not supported.
Deprecated since Python 2.0 but still a part of
UserList
.
-
-
interface
zope.interface.common.sequence.
IExtendedReadSequence
[source]¶ Extends:
zope.interface.common.sequence.IReadSequence
Full read interface for lists
-
count
(item)¶ Return number of occurrences of value
-
index
(item, *args)¶ index(value, [start, [stop]]) -> int
Return first index of value
-
-
interface
zope.interface.common.sequence.
IUniqueMemberWriteSequence
[source]¶ The write contract for a sequence that may enforce unique members
-
__setitem__
(index, item)¶ x.__setitem__(index, item) <==> x[index] = item
Declaring this interface does not specify whether
__setitem__
supports slice objects.
-
__delitem__
(index)¶ x.__delitem__(index) <==> del x[index]
Declaring this interface does not specify whether
__delitem__
supports slice objects.
-
__setslice__
(i, j, other)¶ x.__setslice__(i, j, other) <==> x[i:j] = other
Use of negative indices is not supported.
Deprecated since Python 2.0 but still a part of
UserList
.
-
__delslice__
(i, j)¶ x.__delslice__(i, j) <==> del x[i:j]
Use of negative indices is not supported.
Deprecated since Python 2.0 but still a part of
UserList
.
-
__iadd__
(y)¶ x.__iadd__(y) <==> x += y
-
append
(item)¶ Append item to end
-
insert
(index, item)¶ Insert item before index
-
pop
(index=-1)¶ Remove and return item at index (default last)
-
remove
(item)¶ Remove first occurrence of value
-
reverse
()¶ Reverse IN PLACE
-
sort
(cmpfunc=None)¶ Stable sort IN PLACE;
cmpfunc(x, y)
-> -1, 0, 1
-
extend
(iterable)¶ Extend list by appending elements from the iterable
-
-
interface
zope.interface.common.sequence.
IWriteSequence
[source]¶ Extends:
zope.interface.common.sequence.IUniqueMemberWriteSequence
Full write contract for sequences
-
__imul__
(n)¶ x.__imul__(n) <==> x *= n
-
-
interface
zope.interface.common.sequence.
ISequence
[source]¶ Extends:
zope.interface.common.sequence.IReadSequence
,zope.interface.common.sequence.IWriteSequence
Full sequence contract