sorted(iterable[, cmp[, key[, reverse]]])
In general, the key and reverse conversion processes are much faster than specifying an equivalent cmp function.
next(iterator[, default])
Retrieve the next item from the iterator by calling its next() method.
iter(o[, sentinel])
Return an iterator object. If the second argument, sentinel, is given, then o must be a callable object. The iterator created in this case will call o with no arguments for each call to its next() method; if the value returned is equal to sentinel, StopIteration will be raised, otherwise the value will be returned.
reduce(function, iterable[, initializer]) reduce just like reduce function in couchdb, it takes a list and returns a single value. reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5).
classmethod(function)
A class method receives the class as implicit first argument, just like an instance method receives the instance. To declare a class method, use this idiom:
123
classC:@classmethoddeff(cls,arg1,arg2,...):...
staticmethod(function)
A static method does not receive an implicit first argument. To declare a static method, use this idiom:
123
classC:@staticmethoddeff(arg1,arg2,...):...
property
12345678910111213141516171819
classC(object):def__init__(self):self._x=None# c.x will invoke this method@propertydefx(self):""I'm the 'x' property.""returnself._x# c.x = value will invoke this method@x.setterdefx(self,value):self._x=value# del c.x will invoke this method@x.deleterdefx(self):delself._x
Note This function is not normally available as a built-in since the name print is recognized as the print statement. To disable the statement and use the print() function, use this future statement at the top of your module.