home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
utilities
/
p
/
python
/
!ibrowse
/
files
/
pylibi-4
(
.txt
)
< prev
next >
Wrap
GNU Info File
|
1996-11-14
|
51KB
|
1,023 lines
This is Info file pylibi, produced by Makeinfo-1.55 from the input file
lib.texi.
This file describes the built-in types, exceptions and functions and the
standard modules that come with the Python system. It assumes basic
knowledge about the Python language. For an informal introduction to
the language, see the Python Tutorial. The Python Reference Manual
gives a more formal definition of the language. (These manuals are not
yet available in INFO or Texinfo format.)
Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, The
Netherlands.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Stichting Mathematisch
Centrum or CWI or Corporation for National Research Initiatives or CNRI
not be used in advertising or publicity pertaining to distribution of
the software without specific, written prior permission.
While CWI is the initial source for this software, a modified version
is made available by the Corporation for National Research Initiatives
(CNRI) at the Internet address ftp://ftp.python.org.
STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
File: pylibi, Node: os, Next: time, Prev: Generic Operating System Services, Up: Generic Operating System Services
Standard Module `os'
====================
This module provides a more portable way of using operating system (OS)
dependent functionality than importing an OS dependent built-in module
like `posix'.
When the optional built-in module `posix' is available, this module
exports the same functions and data as `posix'; otherwise, it searches
for an OS dependent built-in module like `mac' and exports the same
functions and data as found there. The design of all Python's built-in
OS dependent modules is such that as long as the same functionality is
available, it uses the same interface; e.g., the function
`os.stat(FILE)' returns stat info about a FILE in a format compatible
with the POSIX interface.
Extensions peculiar to a particular OS are also available through the
`os' module, but using them is of course a threat to portability!
Note that after the first time `os' is imported, there is *no*
performance penalty in using functions from `os' instead of directly
from the OS dependent built-in module, so there should be *no* reason
not to use `os'!
In addition to whatever the correct OS dependent module exports, the
following variables and functions are always exported by `os':
- data of module os: name
The name of the OS dependent module imported. The following names
have currently been registered: `'posix'', `'nt'', `'dos'',
`'mac''.
- data of module os: path
The corresponding OS dependent standard module for pathname
operations, e.g., `posixpath' or `macpath'. Thus, (given the
proper imports), `os.path.split(FILE)' is equivalent to but more
portable than `posixpath.split(FILE)'.
- data of module os: curdir
The constant string used by the OS to refer to the current
directory, e.g. `'.'' for POSIX or `':'' for the Mac.
- data of module os: pardir
The constant string used by the OS to refer to the parent
directory, e.g. `'..'' for POSIX or `'::'' for the Mac.
- data of module os: sep
The character used by the OS to separate pathname components, e.g.
`'/'' for POSIX or `':'' for the Mac. Note that knowing this is
not sufficient to be able to parse or concatenate pathnames--better
use `os.path.split()' and `os.path.join()'--but it is occasionally
useful.
- data of module os: pathsep
The character conventionally used by the OS to separate search
patch components (as in `$PATH'), e.g. `':'' for POSIX or `';''
for MS-DOS.
- data of module os: defpath
The default search path used by `os.exec*p*()' if the environment
doesn't have a `'PATH'' key.
- function of module os: execl (PATH, ARG0, ARG1, ...)
This is equivalent to `os.execv(PATH, (ARG0, ARG1, ...))'.
- function of module os: execle (PATH, ARG0, ARG1, ..., ENV)
This is equivalent to `os.execve(PATH, (ARG0, ARG1, ...), ENV)'.
- function of module os: execlp (PATH, ARG0, ARG1, ...)
This is equivalent to `os.execvp(PATH, (ARG0, ARG1, ...))'.
- function of module os: execvp (PATH, ARGS)
This is like `os.execv(PATH, ARGS)' but duplicates the shell's
actions in searching for an executable file in a list of
directories. The directory list is obtained from
`os.environ['PATH']'.
- function of module os: execvpe (PATH, ARGS, ENV)
This is a cross between `os.execve()' and `os.execvp()'. The
directory list is obtained from `ENV['PATH']'.
(The functions `os.execv()' and `execve()' are not documented here,
since they are implemented by the OS dependent module. If the OS
dependent module doesn't define either of these, the functions that
rely on it will raise an exception. They are documented in the section
on module `posix', together with all other functions that `os' imports
from the OS dependent module.)
File: pylibi, Node: time, Next: getopt, Prev: os, Up: Generic Operating System Services
Built-in Module `time'
======================
This module provides various time-related functions. It is always
available.
An explanation of some terminology and conventions is in order.
* The "epoch" is the point where the time starts. On January 1st of
that year, at 0 hours, the "time since the epoch" is zero. For
UNIX, the epoch is 1970. To find out what the epoch is, look at
`gmtime(0)'.
* UTC is Coordinated Universal Time (formerly known as Greenwich Mean
Time). The acronym UTC is not a mistake but a compromise between
English and French.
* DST is Daylight Saving Time, an adjustment of the timezone by
(usually) one hour during part of the year. DST rules are magic
(determined by local law) and can change from year to year. The C
library has a table containing the local rules (often it is read
from a system file for flexibility) and is the only source of True
Wisdom in this respect.
* The precision of the various real-time functions may be less than
suggested by the units in which their value or argument is
expressed. E.g. on most UNIX systems, the clock "ticks" only 50
or 100 times a second, and on the Mac, times are only accurate to
whole seconds.
* The time tuple as returned by `gmtime()' and `localtime()', or as
accpted by `mktime()' is a tuple of 9 integers: year (e.g. 1993),
month (1-12), day (1-31), hour (0-23), minute (0-59), second
(0-59), weekday (0-6, monday is 0), Julian day (1-366) and
daylight savings flag (-1, 0 or 1). Note that unlike the C
structure, the month value is a range of 1-12, not 0-11. A year
value of 100 will typically be silently converted to 1900 year
value. A -1 argument as daylight savings flag, passed to
`mktime()' will usually result in the correct daylight savings
state to be filled in.
The module defines the following functions and data items:
- data of module time: altzone
The offset of the local DST timezone, in seconds west of the 0th
meridian, if one is defined. Negative if the local DST timezone is
east of the 0th meridian (as in Western Europe, including the UK).
Only use this if `daylight' is nonzero.
- function of module time: asctime (TUPLE)
Convert a tuple representing a time as returned by `gmtime()' or
`localtime()' to a 24-character