Module __builtin__
[hide private]
[frames] | no frames]

Module __builtin__

Built-in functions, exceptions, and other objects.

Noteworthy: None is the `nil' object; Ellipsis represents `...' in slices.

Classes [hide private]
basestring
Type basestring cannot be instantiated; it is the base for str and unicode.
bool
bool(x) -> bool
buffer
buffer(object [, offset[, size]])
classmethod
classmethod(function) -> method
complex
complex(real[, imag]) -> complex number
dict
dict() -> new empty dictionary.
enumerate
enumerate(iterable) -> iterator for index, value of iterable
file
file(name[, mode[, buffering]]) -> file object
float
float(x) -> floating point number
frozenset
frozenset(iterable) --> frozenset object
int
int(x[, base]) -> integer
list
list() -> new list list(sequence) -> new list initialized from sequence's items
long
long(x[, base]) -> integer
object
The most base type
property
property(fget=None, fset=None, fdel=None, doc=None) -> property attribute
reversed
reversed(sequence) -> reverse iterator over values of the sequence
set
set(iterable) --> set object
slice
slice([start,] stop[, step])
staticmethod
staticmethod(function) -> method
str
str(object) -> string
super
super(type) -> unbound super object...
tuple
tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items
type
type(object) -> the object's type type(name, bases, dict) -> a new type
unicode
unicode(string [, encoding[, errors]]) -> object
xrange
xrange([start,] stop[, step]) -> xrange object
Functions [hide private]
 
__import__()
__import__(name, globals={}, locals={}, fromlist=[], level=-1) -> module
number
abs(number)
Return the absolute value of the argument.
bool
all(iterable)
Return True if bool(x) is True for all values x in the iterable.
bool
any(iterable)
Return True if bool(x) is True for any x in the iterable.
value
apply(object, args=..., kwargs=...)
Call a callable object with positional arguments taken from the tuple args, and keyword arguments taken from the optional dictionary kwargs.
bool
callable(object)
Return whether the object is callable (i.e., some kind of function).
character
chr(i)
Return a string of one character with ordinal i; 0 <= i < 256.
integer
cmp(x, y)
Return negative if x<y, zero if x==y, positive if x>y.
(x1, y1)
coerce(x, y)
Return a tuple consisting of the two numeric arguments converted to a common type, using the same rules as used by arithmetic operations.
code object
compile(source, filename, mode, flags=..., dont_inherit=...)
Compile the source string (a Python module, statement or expression) into a code object that can be executed by the exec statement or eval().
 
delattr(object, name)
Delete a named attribute on an object; delattr(x, 'y') is equivalent to ``del x.y''.
list of strings
dir(object=...)
Return an alphabetized list of names comprising (some of) the attributes of the given object, and of attributes reachable from it:
(div, mod)
divmod(x, y)
Return the tuple ((x-x%y)/y, x%y).
value
eval(source, globals=..., locals=...)
Evaluate the source in the context of globals and locals.
 
execfile(filename, globals=..., locals=...)
Read and execute a Python script from a file.
 
filter(...)
filter(function or None, sequence) -> list, tuple, or string
value
getattr(object, name, default=...)
Get a named attribute from an object; getattr(x, 'y') is equivalent to x.y.
dictionary
globals()
Return the dictionary containing the current scope's global variables.
bool
hasattr(object, name)
Return whether the object has an attribute with the given name.
integer
hash(object)
Return a hash value for the object.
string
hex(number)
Return the hexadecimal representation of an integer or long integer.
integer
id(object)
Return the identity of an object.
value
input(prompt=...)
Equivalent to eval(raw_input(prompt)).
string
intern(string)
``Intern'' the given string.
bool
isinstance(object, class-or-type-or-tuple)
Return whether an object is an instance of a class or of a subclass thereof.
bool
issubclass(C, B)
Return whether class C is a subclass (i.e., a derived class) of class B.
iterator
iter(collection)
iter(callable, sentinel) -> iterator
integer
len(object)
Return the number of items of a sequence or mapping.
dictionary
locals()
Update and return a dictionary containing the current scope's local variables.
list
map(function, sequence, sequence=..., ...)
Return a list of the results of applying the function to the items of the argument sequence(s).
value
max(iterable, key=func)
max(a, b, c, ...[, key=func]) -> value
value
min(iterable, key=func)
min(a, b, c, ...[, key=func]) -> value
string
oct(number)
Return the octal representation of an integer or long integer.
file object
open(name, mode=..., buffering=...)
Open a file using the file() type, returns a file object.
integer
ord(c)
Return the integer ordinal of a one-character string.
number
pow(x, y, z=...)
With two arguments, equivalent to x**y.
list of integers
range(start=..., stop, step=...)
Return a list containing an arithmetic progression of integers.
string
raw_input(prompt=...)
Read a string from standard input.
value
reduce(function, sequence, initial=...)
Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value.
module
reload(module)
Reload the module.
string
repr(object)
Return the canonical string representation of the object.
floating point number
round(number, ndigits=...)
Round a number to a given precision in decimal digits (default 0 digits).
 
setattr(object, name, value)
Set a named attribute on an object; setattr(x, 'y', v) is equivalent to ``x.y = v''.
 
sorted(...)
sorted(iterable, cmp=None, key=None, reverse=False) --> new sorted list
value
sum(sequence, start=0)
Returns the sum of a sequence of numbers (NOT strings) plus the value of parameter 'start'.
Unicode character
unichr(i)
Return a Unicode string of one character with ordinal i; 0 <= i <= 0x10ffff.
dictionary
vars(object=...)
Without arguments, equivalent to locals().
 
zip(...)
zip(seq1 [, seq2 [...]]) -> [(seq1[0], seq2[0] ...), (...)]
Variables [hide private]
  Ellipsis = Ellipsis
  False = False
  None = None
  NotImplemented = NotImplemented
  True = True
  __debug__ = True
  copyright = Copyright (c) 2001-2006 Python Software Foundati...
  credits = Thanks to CWI, CNRI, BeOpen.com, Zope Corporatio...
  exit = Use exit() or Ctrl-D (i.e. EOF) to exit
  help = Type help() for interactive help, or help(object) for h...
  license = Type license() to see the full license text
  quit = Use quit() or Ctrl-D (i.e. EOF) to exit

Imports: ArithmeticError, AssertionError, AttributeError, BaseException, DeprecationWarning, EOFError, EnvironmentError, Exception, FloatingPointError, FutureWarning, GeneratorExit, IOError, ImportError, ImportWarning, IndentationError, IndexError, KeyError, KeyboardInterrupt, LookupError, MemoryError, NameError, NotImplementedError, OSError, OverflowError, PendingDeprecationWarning, ReferenceError, RuntimeError, RuntimeWarning, StandardError, StopIteration, SyntaxError, SyntaxWarning, SystemError, SystemExit, TabError, TypeError, UnboundLocalError, UnicodeDecodeError, UnicodeEncodeError, UnicodeError, UnicodeTranslateError, UnicodeWarning, UserWarning, ValueError, Warning, ZeroDivisionError


Function Details [hide private]

__import__()

 

__import__(name, globals={}, locals={}, fromlist=[], level=-1) -> module

Import a module. The globals are only used to determine the context; they are not modified. The locals are currently unused. The fromlist should be a list of names to emulate ``from name import ...'', or an empty list to emulate ``import name''. When importing a module from a package, note that __import__('A.B', ...) returns package A when fromlist is empty, but its submodule B when fromlist is not empty. Level is used to determine whether to perform absolute or relative imports. -1 is the original strategy of attempting both absolute and relative imports, 0 is absolute, a positive number is the number of parent directories to search relative to the current module.

apply(object, args=..., kwargs=...)

 
Call a callable object with positional arguments taken from the tuple args,
and keyword arguments taken from the optional dictionary kwargs.
Note that classes are callable, as are instances with a __call__() method.

Deprecated since release 2.3. Instead, use the extended call syntax:
    function(*args, **keywords).

Returns: value

callable(object)

 

Return whether the object is callable (i.e., some kind of function). Note that classes are callable, as are instances with a __call__() method.

Returns: bool

coerce(x, y)

 

Return a tuple consisting of the two numeric arguments converted to a common type, using the same rules as used by arithmetic operations. If coercion is not possible, raise TypeError.

Returns: (x1, y1)

compile(source, filename, mode, flags=..., dont_inherit=...)

 

Compile the source string (a Python module, statement or expression) into a code object that can be executed by the exec statement or eval(). The filename will be used for run-time error messages. The mode must be 'exec' to compile a module, 'single' to compile a single (interactive) statement, or 'eval' to compile an expression. The flags argument, if present, controls which future statements influence the compilation of the code. The dont_inherit argument, if non-zero, stops the compilation inheriting the effects of any future statements in effect in the code calling compile; if absent or zero these statements do influence the compilation, in addition to any features explicitly specified.

Returns: code object

dir(object=...)

 
Return an alphabetized list of names comprising (some of) the attributes
of the given object, and of attributes reachable from it:

No argument:  the names in the current scope.
Module object:  the module attributes.
Type or class object:  its attributes, and recursively the attributes of
    its bases.
Otherwise:  its attributes, its class's attributes, and recursively the
    attributes of its class's base classes.

Returns: list of strings

divmod(x, y)

 

Return the tuple ((x-x%y)/y, x%y). Invariant: div*y + mod == x.

Returns: (div, mod)

eval(source, globals=..., locals=...)

 

Evaluate the source in the context of globals and locals. The source may be a string representing a Python expression or a code object as returned by compile(). The globals must be a dictionary and locals can be any mapping, defaulting to the current globals and locals. If only globals is given, locals defaults to it.

Returns: value

execfile(filename, globals=..., locals=...)

 

Read and execute a Python script from a file. The globals and locals are dictionaries, defaulting to the current globals and locals. If only globals is given, locals defaults to it.

filter(...)

 

filter(function or None, sequence) -> list, tuple, or string

Return those items of sequence for which function(item) is true. If function is None, return the items that are true. If sequence is a tuple or string, return the same type, else return a list.

getattr(object, name, default=...)

 

Get a named attribute from an object; getattr(x, 'y') is equivalent to x.y. When a default argument is given, it is returned when the attribute doesn't exist; without it, an exception is raised in that case.

Returns: value

hasattr(object, name)

 

Return whether the object has an attribute with the given name. (This is done by calling getattr(object, name) and catching exceptions.)

Returns: bool

hash(object)

 

Return a hash value for the object. Two objects with the same value have the same hash value. The reverse is not necessarily true, but likely.

Returns: integer

id(object)

 

Return the identity of an object. This is guaranteed to be unique among simultaneously existing objects. (Hint: it's the object's memory address.)

Returns: integer

intern(string)

 

``Intern'' the given string. This enters the string in the (global) table of interned strings whose purpose is to speed up dictionary lookups. Return the string itself or the previously interned string object with the same value.

Returns: string

isinstance(object, class-or-type-or-tuple)

 

Return whether an object is an instance of a class or of a subclass thereof. With a type as second argument, return whether that is the object's type. The form using a tuple, isinstance(x, (A, B, ...)), is a shortcut for isinstance(x, A) or isinstance(x, B) or ... (etc.).

Returns: bool

issubclass(C, B)

 

Return whether class C is a subclass (i.e., a derived class) of class B. When using a tuple as the second argument issubclass(X, (A, B, ...)), is a shortcut for issubclass(X, A) or issubclass(X, B) or ... (etc.).

Returns: bool

iter(collection)

 

iter(callable, sentinel) -> iterator

Get an iterator from an object. In the first form, the argument must supply its own iterator, or be a sequence. In the second form, the callable is called until it returns the sentinel.

Returns: iterator

map(function, sequence, sequence=..., ...)

 

Return a list of the results of applying the function to the items of the argument sequence(s). If more than one sequence is given, the function is called with an argument list consisting of the corresponding item of each sequence, substituting None for missing values when not all sequences have the same length. If the function is None, return a list of the items of the sequence (or a list of tuples if more than one sequence).

Returns: list

max(iterable, key=func)

 

max(a, b, c, ...[, key=func]) -> value

With a single iterable argument, return its largest item. With two or more arguments, return the largest argument.

Returns: value

min(iterable, key=func)

 

min(a, b, c, ...[, key=func]) -> value

With a single iterable argument, return its smallest item. With two or more arguments, return the smallest argument.

Returns: value

pow(x, y, z=...)

 

With two arguments, equivalent to x**y. With three arguments, equivalent to (x**y) % z, but may be more efficient (e.g. for longs).

Returns: number

range(start=..., stop, step=...)

 

Return a list containing an arithmetic progression of integers. range(i, j) returns [i, i+1, i+2, ..., j-1]; start (!) defaults to 0. When step is given, it specifies the increment (or decrement). For example, range(4) returns [0, 1, 2, 3]. The end point is omitted! These are exactly the valid indices for a list of 4 elements.

Returns: list of integers

raw_input(prompt=...)

 

Read a string from standard input. The trailing newline is stripped. If the user hits EOF (Unix: Ctl-D, Windows: Ctl-Z+Return), raise EOFError. On Unix, GNU readline is used if enabled. The prompt string, if given, is printed without a trailing newline before reading.

Returns: string

reduce(function, sequence, initial=...)

 

Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items of the sequence in the calculation, and serves as a default when the sequence is empty.

Returns: value

reload(module)

 

Reload the module. The module must have been successfully imported before.

Returns: module

repr(object)

 

Return the canonical string representation of the object. For most object types, eval(repr(object)) == object.

Returns: string

round(number, ndigits=...)

 

Round a number to a given precision in decimal digits (default 0 digits). This always returns a floating point number. Precision may be negative.

Returns: floating point number

sum(sequence, start=0)

 

Returns the sum of a sequence of numbers (NOT strings) plus the value of parameter 'start'. When the sequence is empty, returns start.

Returns: value

vars(object=...)

 

Without arguments, equivalent to locals(). With an argument, equivalent to object.__dict__.

Returns: dictionary

zip(...)

 

zip(seq1 [, seq2 [...]]) -> [(seq1[0], seq2[0] ...), (...)]

Return a list of tuples, where each tuple contains the i-th element from each of the argument sequences. The returned list is truncated in length to the length of the shortest argument sequence.


Variables Details [hide private]

copyright

Value:
Copyright (c) 2001-2006 Python Software Foundation.
All Rights Reserved.

Copyright (c) 2000 BeOpen.com.
All Rights Reserved.

Copyright (c) 1995-2001 Corporation for National Research Initiatives.
All Rights Reserved.
...

credits

Value:
    Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of th\
ousands
    for supporting Python development.  See www.python.org for more in\
formation.

help

Value:
Type help() for interactive help, or help(object) for help about objec\
t.