Python's Built-In Functions

Built into the Python interpreter are a number of functions (pieces of code that carry out specific operations and return the results of those operations), including math functions other than the standard arithmetic operators. Here's a list of Python's built-in functions along with their pattern and corresponding action:



















































































SyntaxAction
abs(number)Return absolute value of number
all(iterable)Return True unless at least one element is false
any(iterable)Return False unless at least one element is true
chr(integer)Return the character with the specified ASCII value (must be
between 0 and 256)
delattr(object, name), del x.yDelete the named attribute from object
dir([object])Return the names in the current namespace or object's
namespace
eval(source[, globals[, locals]])Execute source as a Python expression
getattr(object, name[, default]) x.yReturn specified attribute (name) of object,
raising AttributeError if not found; optional: return
default if name doesn't exist
globals()Return dict of global names in the current namespace
hasattr(object, name)True if object has the specified attribute
(name)
isinstance(object, class-or-type)True if object is an instance of the specified class (or
its subclasses) or type; optional: specify multiple classes or
types using a tuple
issubclass(C, B)True if class C is a subclass of class B;
optional: specify multiple classes using a tuple
iter(iterable)Return an iterator over iterable
len(object)Return number of items in a sequence or dict
locals()Return dictionary of local names in the current namespace
max(iterable), max(a, b, c, ...)Return largest item of iterable or argument list
min(iterable), min(a, b, c, ...)Return smallest item of iterable or argument list
ord(char)Return the ASCII value of a one-character string
range([start,] stop[, step])Return a list of integers from 0 up to (but not
including) stop










































raw_input([prompt])Return a string from standard input (usually something the user
types), not including the newline character
repr(object)Return canonical string representation of object
round(number[, ndigits])Return floating-point number rounded to nearest integer
setattr(object, name, value) x.y = vSet object's attribute to the specified value
sorted(iterable[, cmp [, key [, reverse])Return a new sorted list; optional: cmp and key
take functions as arguments; reverse=True
sum(iterable[, start=0])Return the sum of all elements of iterable; does not
work with strings
unichr(integer)Return a Unicode string corresponding to integer, which
must be between 0 and 0x10ffff
xrange([start,] stop[, step])Return an iterable that generates a range from 0 up to
(but not including) stop
zip([iter1 [, iter2 [, ...]]])Take zero or more iterables and return a list of tuples that
group the items at a particular index number; the list returned is
the same length as the shortest iterable








dummies

Source:http://www.dummies.com/how-to/content/pythons-builtin-functions.html

No comments:

Post a Comment