You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

435 lines
13 KiB

32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
24 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
  1. .TH PYTHON "1" "$Date$"
  2. .\" To view this file while editing, run it through groff:
  3. .\" groff -Tascii -man python.man | less
  4. .SH NAME
  5. python \- an interpreted, interactive, object-oriented programming language
  6. .SH SYNOPSIS
  7. .B python
  8. [
  9. .B \-B
  10. ]
  11. [
  12. .B \-d
  13. ]
  14. [
  15. .B \-E
  16. ]
  17. [
  18. .B \-h
  19. ]
  20. [
  21. .B \-i
  22. ]
  23. [
  24. .B \-m
  25. .I module-name
  26. ]
  27. [
  28. .B \-q
  29. ]
  30. .br
  31. [
  32. .B \-O
  33. ]
  34. [
  35. .B \-OO
  36. ]
  37. [
  38. .B \-s
  39. ]
  40. [
  41. .B \-S
  42. ]
  43. [
  44. .B \-u
  45. ]
  46. .br
  47. [
  48. .B \-v
  49. ]
  50. [
  51. .B \-V
  52. ]
  53. [
  54. .B \-W
  55. .I argument
  56. ]
  57. [
  58. .B \-x
  59. ]
  60. [
  61. .B \-?
  62. ]
  63. .br
  64. [
  65. .B \-c
  66. .I command
  67. |
  68. .I script
  69. |
  70. \-
  71. ]
  72. [
  73. .I arguments
  74. ]
  75. .SH DESCRIPTION
  76. Python is an interpreted, interactive, object-oriented programming
  77. language that combines remarkable power with very clear syntax.
  78. For an introduction to programming in Python you are referred to the
  79. Python Tutorial.
  80. The Python Library Reference documents built-in and standard types,
  81. constants, functions and modules.
  82. Finally, the Python Reference Manual describes the syntax and
  83. semantics of the core language in (perhaps too) much detail.
  84. (These documents may be located via the
  85. .B "INTERNET RESOURCES"
  86. below; they may be installed on your system as well.)
  87. .PP
  88. Python's basic power can be extended with your own modules written in
  89. C or C++.
  90. On most systems such modules may be dynamically loaded.
  91. Python is also adaptable as an extension language for existing
  92. applications.
  93. See the internal documentation for hints.
  94. .PP
  95. Documentation for installed Python modules and packages can be
  96. viewed by running the
  97. .B pydoc
  98. program.
  99. .SH COMMAND LINE OPTIONS
  100. .TP
  101. .B \-B
  102. Don't write
  103. .I .py[co]
  104. files on import. See also PYTHONDONTWRITEBYTECODE.
  105. .TP
  106. .BI "\-c " command
  107. Specify the command to execute (see next section).
  108. This terminates the option list (following options are passed as
  109. arguments to the command).
  110. .TP
  111. .B \-d
  112. Turn on parser debugging output (for wizards only, depending on
  113. compilation options).
  114. .TP
  115. .B \-E
  116. Ignore environment variables like PYTHONPATH and PYTHONHOME that modify
  117. the behavior of the interpreter.
  118. .TP
  119. .B \-h ", " \-? ", "\-\-help
  120. Prints the usage for the interpreter executable and exits.
  121. .TP
  122. .B \-i
  123. When a script is passed as first argument or the \fB\-c\fP option is
  124. used, enter interactive mode after executing the script or the
  125. command. It does not read the $PYTHONSTARTUP file. This can be
  126. useful to inspect global variables or a stack trace when a script
  127. raises an exception.
  128. .TP
  129. .BI "\-m " module-name
  130. Searches
  131. .I sys.path
  132. for the named module and runs the corresponding
  133. .I .py
  134. file as a script.
  135. .TP
  136. .B \-O
  137. Turn on basic optimizations. This changes the filename extension for
  138. compiled (bytecode) files from
  139. .I .pyc
  140. to \fI.pyo\fP. Given twice, causes docstrings to be discarded.
  141. .TP
  142. .B \-OO
  143. Discard docstrings in addition to the \fB-O\fP optimizations.
  144. .TP
  145. .B \-q
  146. Do not print the version and copyright messages. These messages are
  147. also suppressed in non-interactive mode.
  148. .TP
  149. .B \-s
  150. Don't add user site directory to sys.path.
  151. .TP
  152. .B \-S
  153. Disable the import of the module
  154. .I site
  155. and the site-dependent manipulations of
  156. .I sys.path
  157. that it entails. Also disable these manipulations if
  158. .I site
  159. is explicitly imported later.
  160. .TP
  161. .B \-u
  162. Force the binary I/O layers of stdin, stdout and stderr to be unbuffered.
  163. The text I/O layer will still be line-buffered.
  164. .\" Note that there is internal buffering in readlines() and
  165. .\" file-object iterators ("for line in sys.stdin") which is not
  166. .\" influenced by this option. To work around this, you will want to use
  167. .\" "sys.stdin.readline()" inside a "while 1:" loop.
  168. .TP
  169. .B \-v
  170. Print a message each time a module is initialized, showing the place
  171. (filename or built-in module) from which it is loaded. When given
  172. twice, print a message for each file that is checked for when
  173. searching for a module. Also provides information on module cleanup
  174. at exit.
  175. .TP
  176. .B \-V ", " \-\-version
  177. Prints the Python version number of the executable and exits.
  178. .TP
  179. .BI "\-W " argument
  180. Warning control. Python sometimes prints warning message to
  181. .IR sys.stderr .
  182. A typical warning message has the following form:
  183. .IB file ":" line ": " category ": " message.
  184. By default, each warning is printed once for each source line where it
  185. occurs. This option controls how often warnings are printed.
  186. Multiple
  187. .B \-W
  188. options may be given; when a warning matches more than one
  189. option, the action for the last matching option is performed.
  190. Invalid
  191. .B \-W
  192. options are ignored (a warning message is printed about invalid
  193. options when the first warning is issued). Warnings can also be
  194. controlled from within a Python program using the
  195. .I warnings
  196. module.
  197. The simplest form of
  198. .I argument
  199. is one of the following
  200. .I action
  201. strings (or a unique abbreviation):
  202. .B ignore
  203. to ignore all warnings;
  204. .B default
  205. to explicitly request the default behavior (printing each warning once
  206. per source line);
  207. .B all
  208. to print a warning each time it occurs (this may generate many
  209. messages if a warning is triggered repeatedly for the same source
  210. line, such as inside a loop);
  211. .B module
  212. to print each warning only the first time it occurs in each
  213. module;
  214. .B once
  215. to print each warning only the first time it occurs in the program; or
  216. .B error
  217. to raise an exception instead of printing a warning message.
  218. The full form of
  219. .I argument
  220. is
  221. .IB action : message : category : module : line.
  222. Here,
  223. .I action
  224. is as explained above but only applies to messages that match the
  225. remaining fields. Empty fields match all values; trailing empty
  226. fields may be omitted. The
  227. .I message
  228. field matches the start of the warning message printed; this match is
  229. case-insensitive. The
  230. .I category
  231. field matches the warning category. This must be a class name; the
  232. match test whether the actual warning category of the message is a
  233. subclass of the specified warning category. The full class name must
  234. be given. The
  235. .I module
  236. field matches the (fully-qualified) module name; this match is
  237. case-sensitive. The
  238. .I line
  239. field matches the line number, where zero matches all line numbers and
  240. is thus equivalent to an omitted line number.
  241. .TP
  242. .B \-x
  243. Skip the first line of the source. This is intended for a DOS
  244. specific hack only. Warning: the line numbers in error messages will
  245. be off by one!
  246. .SH INTERPRETER INTERFACE
  247. The interpreter interface resembles that of the UNIX shell: when
  248. called with standard input connected to a tty device, it prompts for
  249. commands and executes them until an EOF is read; when called with a
  250. file name argument or with a file as standard input, it reads and
  251. executes a
  252. .I script
  253. from that file;
  254. when called with
  255. .B \-c
  256. .IR command ,
  257. it executes the Python statement(s) given as
  258. .IR command .
  259. Here
  260. .I command
  261. may contain multiple statements separated by newlines.
  262. Leading whitespace is significant in Python statements!
  263. In non-interactive mode, the entire input is parsed before it is
  264. executed.
  265. .PP
  266. If available, the script name and additional arguments thereafter are
  267. passed to the script in the Python variable
  268. .IR sys.argv ,
  269. which is a list of strings (you must first
  270. .I import sys
  271. to be able to access it).
  272. If no script name is given,
  273. .I sys.argv[0]
  274. is an empty string; if
  275. .B \-c
  276. is used,
  277. .I sys.argv[0]
  278. contains the string
  279. .I '-c'.
  280. Note that options interpreted by the Python interpreter itself
  281. are not placed in
  282. .IR sys.argv .
  283. .PP
  284. In interactive mode, the primary prompt is `>>>'; the second prompt
  285. (which appears when a command is not complete) is `...'.
  286. The prompts can be changed by assignment to
  287. .I sys.ps1
  288. or
  289. .IR sys.ps2 .
  290. The interpreter quits when it reads an EOF at a prompt.
  291. When an unhandled exception occurs, a stack trace is printed and
  292. control returns to the primary prompt; in non-interactive mode, the
  293. interpreter exits after printing the stack trace.
  294. The interrupt signal raises the
  295. .I Keyboard\%Interrupt
  296. exception; other UNIX signals are not caught (except that SIGPIPE is
  297. sometimes ignored, in favor of the
  298. .I IOError
  299. exception). Error messages are written to stderr.
  300. .SH FILES AND DIRECTORIES
  301. These are subject to difference depending on local installation
  302. conventions; ${prefix} and ${exec_prefix} are installation-dependent
  303. and should be interpreted as for GNU software; they may be the same.
  304. The default for both is \fI/usr/local\fP.
  305. .IP \fI${exec_prefix}/bin/python\fP
  306. Recommended location of the interpreter.
  307. .PP
  308. .I ${prefix}/lib/python<version>
  309. .br
  310. .I ${exec_prefix}/lib/python<version>
  311. .RS
  312. Recommended locations of the directories containing the standard
  313. modules.
  314. .RE
  315. .PP
  316. .I ${prefix}/include/python<version>
  317. .br
  318. .I ${exec_prefix}/include/python<version>
  319. .RS
  320. Recommended locations of the directories containing the include files
  321. needed for developing Python extensions and embedding the
  322. interpreter.
  323. .RE
  324. .SH ENVIRONMENT VARIABLES
  325. .IP PYTHONHOME
  326. Change the location of the standard Python libraries. By default, the
  327. libraries are searched in ${prefix}/lib/python<version> and
  328. ${exec_prefix}/lib/python<version>, where ${prefix} and ${exec_prefix}
  329. are installation-dependent directories, both defaulting to
  330. \fI/usr/local\fP. When $PYTHONHOME is set to a single directory, its value
  331. replaces both ${prefix} and ${exec_prefix}. To specify different values
  332. for these, set $PYTHONHOME to ${prefix}:${exec_prefix}.
  333. .IP PYTHONPATH
  334. Augments the default search path for module files.
  335. The format is the same as the shell's $PATH: one or more directory
  336. pathnames separated by colons.
  337. Non-existent directories are silently ignored.
  338. The default search path is installation dependent, but generally
  339. begins with ${prefix}/lib/python<version> (see PYTHONHOME above).
  340. The default search path is always appended to $PYTHONPATH.
  341. If a script argument is given, the directory containing the script is
  342. inserted in the path in front of $PYTHONPATH.
  343. The search path can be manipulated from within a Python program as the
  344. variable
  345. .IR sys.path .
  346. .IP PYTHONSTARTUP
  347. If this is the name of a readable file, the Python commands in that
  348. file are executed before the first prompt is displayed in interactive
  349. mode.
  350. The file is executed in the same name space where interactive commands
  351. are executed so that objects defined or imported in it can be used
  352. without qualification in the interactive session.
  353. You can also change the prompts
  354. .I sys.ps1
  355. and
  356. .I sys.ps2
  357. in this file.
  358. .IP PYTHONY2K
  359. Set this to a non-empty string to cause the \fItime\fP module to
  360. require dates specified as strings to include 4-digit years, otherwise
  361. 2-digit years are converted based on rules described in the \fItime\fP
  362. module documentation.
  363. .IP PYTHONOPTIMIZE
  364. If this is set to a non-empty string it is equivalent to specifying
  365. the \fB\-O\fP option. If set to an integer, it is equivalent to
  366. specifying \fB\-O\fP multiple times.
  367. .IP PYTHONDEBUG
  368. If this is set to a non-empty string it is equivalent to specifying
  369. the \fB\-d\fP option. If set to an integer, it is equivalent to
  370. specifying \fB\-d\fP multiple times.
  371. .IP PYTHONDONTWRITEBYTECODE
  372. If this is set to a non-empty string it is equivalent to specifying
  373. the \fB\-B\fP option (don't try to write
  374. .I .py[co]
  375. files).
  376. .IP PYTHONINSPECT
  377. If this is set to a non-empty string it is equivalent to specifying
  378. the \fB\-i\fP option.
  379. .IP PYTHONIOENCODING
  380. If this is set before running the interpreter, it overrides the encoding used
  381. for stdin/stdout/stderr, in the syntax
  382. .IB encodingname ":" errorhandler
  383. The
  384. .IB errorhandler
  385. part is optional and has the same meaning as in str.encode. For stderr, the
  386. .IB errorhandler
  387. part is ignored; the handler will always be \'backslashreplace\'.
  388. .IP PYTHONNOUSERSITE
  389. If this is set to a non-empty string it is equivalent to specifying the
  390. \fB\-s\fP option (Don't add the user site directory to sys.path).
  391. .IP PYTHONUNBUFFERED
  392. If this is set to a non-empty string it is equivalent to specifying
  393. the \fB\-u\fP option.
  394. .IP PYTHONVERBOSE
  395. If this is set to a non-empty string it is equivalent to specifying
  396. the \fB\-v\fP option. If set to an integer, it is equivalent to
  397. specifying \fB\-v\fP multiple times.
  398. .IP PYTHONWARNINGS
  399. If this is set to a comma-separated string it is equivalent to
  400. specifying the \fB\-W\fP option for each separate value.
  401. .IP PYTHONHASHSEED
  402. If this variable is set to "random", a random value is used to seed the hashes
  403. of str, bytes and datetime objects.
  404. If PYTHONHASHSEED is set to an integer value, it is used as a fixed seed for
  405. generating the hash() of the types covered by the hash randomization. Its
  406. purpose is to allow repeatable hashing, such as for selftests for the
  407. interpreter itself, or to allow a cluster of python processes to share hash
  408. values.
  409. The integer must be a decimal number in the range [0,4294967295]. Specifying
  410. the value 0 will disable hash randomization.
  411. .SH AUTHOR
  412. The Python Software Foundation: http://www.python.org/psf
  413. .SH INTERNET RESOURCES
  414. Main website: http://www.python.org/
  415. .br
  416. Documentation: http://docs.python.org/py3k/
  417. .br
  418. Developer resources: http://docs.python.org/devguide/
  419. .br
  420. Downloads: http://python.org/download/
  421. .br
  422. Module repository: http://pypi.python.org/
  423. .br
  424. Newsgroups: comp.lang.python, comp.lang.python.announce
  425. .SH LICENSING
  426. Python is distributed under an Open Source license. See the file
  427. "LICENSE" in the Python source distribution for information on terms &
  428. conditions for accessing and otherwise using Python and for a
  429. DISCLAIMER OF ALL WARRANTIES.