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 >
GNU Info File  |  1996-11-14  |  51KB  |  1,023 lines

  1. This is Info file pylibi, produced by Makeinfo-1.55 from the input file
  2. lib.texi.
  3. This file describes the built-in types, exceptions and functions and the
  4. standard modules that come with the Python system.  It assumes basic
  5. knowledge about the Python language.  For an informal introduction to
  6. the language, see the Python Tutorial.  The Python Reference Manual
  7. gives a more formal definition of the language.  (These manuals are not
  8. yet available in INFO or Texinfo format.)
  9. Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, The
  10. Netherlands.
  11. All Rights Reserved
  12. Permission to use, copy, modify, and distribute this software and its
  13. documentation for any purpose and without fee is hereby granted,
  14. provided that the above copyright notice appear in all copies and that
  15. both that copyright notice and this permission notice appear in
  16. supporting documentation, and that the names of Stichting Mathematisch
  17. Centrum or CWI or Corporation for National Research Initiatives or CNRI
  18. not be used in advertising or publicity pertaining to distribution of
  19. the software without specific, written prior permission.
  20. While CWI is the initial source for this software, a modified version
  21. is made available by the Corporation for National Research Initiatives
  22. (CNRI) at the Internet address ftp://ftp.python.org.
  23. STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
  24. REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
  25. MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
  26. CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
  27. DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  28. PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
  29. ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
  30. THIS SOFTWARE.
  31. File: pylibi,  Node: os,  Next: time,  Prev: Generic Operating System Services,  Up: Generic Operating System Services
  32. Standard Module `os'
  33. ====================
  34. This module provides a more portable way of using operating system (OS)
  35. dependent functionality than importing an OS dependent built-in module
  36. like `posix'.
  37. When the optional built-in module `posix' is available, this module
  38. exports the same functions and data as `posix'; otherwise, it searches
  39. for an OS dependent built-in module like `mac' and exports the same
  40. functions and data as found there.  The design of all Python's built-in
  41. OS dependent modules is such that as long as the same functionality is
  42. available, it uses the same interface; e.g., the function
  43. `os.stat(FILE)' returns stat info about a FILE in a format compatible
  44. with the POSIX interface.
  45. Extensions peculiar to a particular OS are also available through the
  46. `os' module, but using them is of course a threat to portability!
  47. Note that after the first time `os' is imported, there is *no*
  48. performance penalty in using functions from `os' instead of directly
  49. from the OS dependent built-in module, so there should be *no* reason
  50. not to use `os'!
  51. In addition to whatever the correct OS dependent module exports, the
  52. following variables and functions are always exported by `os':
  53.  - data of module os: name
  54.      The name of the OS dependent module imported.  The following names
  55.      have currently been registered: `'posix'', `'nt'', `'dos'',
  56.      `'mac''.
  57.  - data of module os: path
  58.      The corresponding OS dependent standard module for pathname
  59.      operations, e.g., `posixpath' or `macpath'.  Thus, (given the
  60.      proper imports), `os.path.split(FILE)' is equivalent to but more
  61.      portable than `posixpath.split(FILE)'.
  62.  - data of module os: curdir
  63.      The constant string used by the OS to refer to the current
  64.      directory, e.g. `'.'' for POSIX or `':'' for the Mac.
  65.  - data of module os: pardir
  66.      The constant string used by the OS to refer to the parent
  67.      directory, e.g. `'..'' for POSIX or `'::'' for the Mac.
  68.  - data of module os: sep
  69.      The character used by the OS to separate pathname components, e.g.
  70.      `'/'' for POSIX or `':'' for the Mac.  Note that knowing this is
  71.      not sufficient to be able to parse or concatenate pathnames--better
  72.      use `os.path.split()' and `os.path.join()'--but it is occasionally
  73.      useful.
  74.  - data of module os: pathsep
  75.      The character conventionally used by the OS to separate search
  76.      patch components (as in `$PATH'), e.g. `':'' for POSIX or `';''
  77.      for MS-DOS.
  78.  - data of module os: defpath
  79.      The default search path used by `os.exec*p*()' if the environment
  80.      doesn't have a `'PATH'' key.
  81.  - function of module os: execl (PATH, ARG0, ARG1, ...)
  82.      This is equivalent to `os.execv(PATH, (ARG0, ARG1, ...))'.
  83.  - function of module os: execle (PATH, ARG0, ARG1, ..., ENV)
  84.      This is equivalent to `os.execve(PATH, (ARG0, ARG1, ...), ENV)'.
  85.  - function of module os: execlp (PATH, ARG0, ARG1, ...)
  86.      This is equivalent to `os.execvp(PATH, (ARG0, ARG1, ...))'.
  87.  - function of module os: execvp (PATH, ARGS)
  88.      This is like `os.execv(PATH, ARGS)' but duplicates the shell's
  89.      actions in searching for an executable file in a list of
  90.      directories.  The directory list is obtained from
  91.      `os.environ['PATH']'.
  92.  - function of module os: execvpe (PATH, ARGS, ENV)
  93.      This is a cross between `os.execve()' and `os.execvp()'.  The
  94.      directory list is obtained from `ENV['PATH']'.
  95. (The functions `os.execv()' and `execve()' are not documented here,
  96. since they are implemented by the OS dependent module.  If the OS
  97. dependent module doesn't define either of these, the functions that
  98. rely on it will raise an exception.  They are documented in the section
  99. on module `posix', together with all other functions that `os' imports
  100. from the OS dependent module.)
  101. File: pylibi,  Node: time,  Next: getopt,  Prev: os,  Up: Generic Operating System Services
  102. Built-in Module `time'
  103. ======================
  104. This module provides various time-related functions.  It is always
  105. available.
  106. An explanation of some terminology and conventions is in order.
  107.    * The "epoch" is the point where the time starts.  On January 1st of
  108.      that year, at 0 hours, the "time since the epoch" is zero.  For
  109.      UNIX, the epoch is 1970.  To find out what the epoch is, look at
  110.      `gmtime(0)'.
  111.    * UTC is Coordinated Universal Time (formerly known as Greenwich Mean
  112.      Time).  The acronym UTC is not a mistake but a compromise between
  113.      English and French.
  114.    * DST is Daylight Saving Time, an adjustment of the timezone by
  115.      (usually) one hour during part of the year.  DST rules are magic
  116.      (determined by local law) and can change from year to year.  The C
  117.      library has a table containing the local rules (often it is read
  118.      from a system file for flexibility) and is the only source of True
  119.      Wisdom in this respect.
  120.    * The precision of the various real-time functions may be less than
  121.      suggested by the units in which their value or argument is
  122.      expressed.  E.g. on most UNIX systems, the clock "ticks" only 50
  123.      or 100 times a second, and on the Mac, times are only accurate to
  124.      whole seconds.
  125.    * The time tuple as returned by `gmtime()' and `localtime()', or as
  126.      accpted by `mktime()' is a tuple of 9 integers: year (e.g. 1993),
  127.      month (1-12), day (1-31), hour (0-23), minute (0-59), second
  128.      (0-59), weekday (0-6, monday is 0), Julian day (1-366) and
  129.      daylight savings flag (-1, 0  or 1).  Note that unlike the C
  130.      structure, the month value is a range of 1-12, not 0-11.  A year
  131.      value of  100 will typically be silently converted to 1900  year
  132.      value.  A -1 argument as daylight savings flag, passed to
  133.      `mktime()' will usually result in the correct daylight savings
  134.      state to be filled in.
  135. The module defines the following functions and data items:
  136.  - data of module time: altzone
  137.      The offset of the local DST timezone, in seconds west of the 0th
  138.      meridian, if one is defined.  Negative if the local DST timezone is
  139.      east of the 0th meridian (as in Western Europe, including the UK).
  140.      Only use this if `daylight' is nonzero.
  141.  - function of module time: asctime (TUPLE)
  142.      Convert a tuple representing a time as returned by `gmtime()' or
  143.      `localtime()' to a 24-character