operator. While undocumented, the concept is real simply:
operator.__add__(x, y)does exactly the same thing as
x+y(for all types -- built-in, user-defined, extension-defined). As a convenience,
operator.adddoes the same thing, but beware -- you can't use
operator.andand a few others where the ``natural'' name for an operator is a reserved keyword. You can add a single trailing underscore in such cases.
errno. See the Library Reference Manual.
cgimodule. See the Library Reference Manual.
rexec). New module
Bastion. Both are now documented in a new chapter on restricted execution in the Library Reference Manual.
rstrip()(strip only the left/right whitespace),
capitalize()(uppercase the first character, lowercase the rest),
capwords()(capitalize each word, delimited a la
translate()(string transliteration - this existed before but can now also delete characters by specifying a third argument),
maketrans()(a convenience function for creating translation tables for
regex.compile()). The string function
split()has an optional third argument which specifies the maximum number of separators to split; e.g.
string.split('a=b=c', '=', 1)yields
['a', 'b=c']. (Note that for a long time,
string.capwords()but allows you to specify the word delimiter as a regular expression),
regsub.split()but returns the delimiters as well as the words in the resulting list). The optional
maxsepargument is also supported by
profile.pycan now be invoked as scripts to debug c.q. profile other scripts easily. For example:
python /usr/local/lib/python1.4/profile.py myscript.py
osmodule now supports the
putenv()function on systems where it is provided in the C library (Windows NT and most Unix versions). For example,
os.putenv('PATH', '/bin:/usr/bin')sets the environment variable
PATHto the string
'/bin:/usr/bin'. Such changes to the environment affect subprocesses started with
putenv()is supported, assignments to items in
os.environare automatically translated into corresponding calls to
os.putenv(); however, calls to
os.environ, so it is actually preferable to assign to items of
os.environ. For this purpose, the type of
os.environis changed to a subclass of
os.putenv()is supported. (Buglet:
os.execve()still requires a real dictionary, so it won't accept
os.environas its third argument. However, you can now use
os.execv()and it will use your changes to
ftruncate. See the Unix manual (section 2, system calls) for these function. More functions are also available under NT.
:-)). See the Library Reference Manual.
sys.path, is the directory containing the script that was used to invoke the Python interpreter. If the script directory is not available (e.g. if the interpreter is invoked interactively or if the script is read from standard input),
sys.pathis the empty string, which directs Python to search modules in the current directory first. Notice that the script directory is inserted before the entries inserted as a result of
$PYTHONPATH. There is no longer an entry for the current directory later in the path (unless explicitly set in
$PYTHONPATHor overridden at build time).