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.add
does the
same thing, but beware -- you can't use operator.and
and 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.cgi
module. 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.lstrip()
, rstrip()
(strip only the left/right
whitespace), capitalize()
(uppercase the first character,
lowercase the rest), capwords()
(capitalize each word,
delimited a la string.split()
), 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
translate()
and 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, split()
and splitfields()
are synonyms.regsub.capwords()
(like string.capwords()
but allows you to
specify the word delimiter as a regular expression),
regsub.splitx()
(like regsub.split()
but returns the
delimiters as well as the words in the resulting list). The optional
maxsep
argument is also supported by regsub.split()
.pdb.py
and profile.py
can 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
os
module 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 PATH
to the
string '/bin:/usr/bin'
. Such changes to the environment affect
subprocesses started with os.system()
, os.popen()
or
os.fork()
and os.execv()
. When putenv()
is
supported, assignments to items in os.environ
are automatically
translated into corresponding calls to os.putenv()
; however,
calls to os.putenv()
don't update os.environ
, so it is
actually preferable to assign to items of os.environ
. For this
purpose, the type of os.environ
is changed to a subclass of
UserDict.UserDict
when os.putenv()
is supported.
(Buglet: os.execve()
still requires a real dictionary, so it
won't accept os.environ
as its third argument. However, you
can now use os.execv()
and it will use your changes to
os.environ
!.)os
module: mkfifo
,
plock
, remove
(== unlink
), and ftruncate
.
See the Unix manual (section 2, system calls) for these function.
More functions are also available under NT.lockf()
and flock()
(don't ask :-)
). See the Library Reference Manual.sys.path[0]
, 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.path[0]
is 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
$PYTHONPATH
or overridden at build time).