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.

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