1PYTHON(1)                   General Commands Manual                  PYTHON(1)
2
3
4

NAME

6       python  - an interpreted, interactive, object-oriented programming lan‐
7       guage
8

SYNOPSIS

10       python [ -B ] [ -b ] [ -d ] [ -E ] [ -h ] [ -i ] [ -I ]
11              [ -m module-name ] [ -q ] [ -O ] [ -OO ] [ -s ] [ -S ] [ -u ]
12              [ -v ] [ -V ] [ -W argument ] [ -x ] [ [ -X option ] -?  ]
13              [ -c command | script | - ] [ arguments ]
14

DESCRIPTION

16       Python is an interpreted, interactive, object-oriented programming lan‐
17       guage  that  combines  remarkable power with very clear syntax.  For an
18       introduction to programming in Python, see the  Python  Tutorial.   The
19       Python  Library  Reference  documents built-in and standard types, con‐
20       stants, functions and modules.  Finally, the  Python  Reference  Manual
21       describes  the  syntax  and  semantics of the core language in (perhaps
22       too) much detail.  (These documents may be  located  via  the  INTERNET
23       RESOURCES below; they may be installed on your system as well.)
24
25       Python's basic power can be extended with your own modules written in C
26       or C++.  On most  systems  such  modules  may  be  dynamically  loaded.
27       Python is also adaptable as an extension language for existing applica‐
28       tions.  See the internal documentation for hints.
29
30       Documentation for installed Python modules and packages can  be  viewed
31       by running the pydoc program.
32

COMMAND LINE OPTIONS

34       -B     Don't  write  .py[co] files on import. See also PYTHONDONTWRITE‐
35              BYTECODE.
36
37       -b     Issue   warnings    about    str(bytes_instance),    str(bytear‐
38              ray_instance)  and  comparing  bytes/bytearray  with  str. (-bb:
39              issue errors)
40
41       -c command
42              Specify the command to execute (see next section).  This  termi‐
43              nates the option list (following options are passed as arguments
44              to the command).
45
46       -d     Turn on parser debugging output (for wizards only, depending  on
47              compilation options).
48
49       -E     Ignore environment variables like PYTHONPATH and PYTHONHOME that
50              modify the behavior of the interpreter.
51
52       -h ,  -? ,  --help
53              Prints the usage for the interpreter executable and exits.
54
55       -i     When a script is passed as first argument or the  -c  option  is
56              used,  enter  interactive mode after executing the script or the
57              command.  It does not read the $PYTHONSTARTUP file.  This can be
58              useful  to  inspect  global  variables  or  a stack trace when a
59              script raises an exception.
60
61       -I     Run Python in isolated mode. This also implies  -E  and  -s.  In
62              isolated  mode  sys.path contains neither the script’s directory
63              nor the user’s site-packages directory. All PYTHON*  environment
64              variables are ignored, too.  Further restrictions may be imposed
65              to prevent the user from injecting malicious code.
66
67       -m module-name
68              Searches sys.path for the named module and runs the  correspond‐
69              ing .py file as a script.
70
71       -O     Turn  on  basic optimizations.  This changes the filename exten‐
72              sion for compiled (bytecode) files from  .pyc  to  .pyo.   Given
73              twice, causes docstrings to be discarded.
74
75       -OO    Discard docstrings in addition to the -O optimizations.
76
77       -q     Do  not print the version and copyright messages. These messages
78              are also suppressed in non-interactive mode.
79
80       -s     Don't add user site directory to sys.path.
81
82       -S     Disable the import of the module  site  and  the  site-dependent
83              manipulations  of  sys.path that it entails.  Also disable these
84              manipulations if site is explicitly imported later.
85
86       -u     Force  the  binary  I/O  layers  of  stdout  and  stderr  to  be
87              unbuffered.   stdin is always buffered.  The text I/O layer will
88              still be line-buffered.
89
90       -v     Print a message each time a module is initialized,  showing  the
91              place  (filename  or  built-in  module) from which it is loaded.
92              When given twice, print a message for each file that is  checked
93              for  when  searching for a module.  Also provides information on
94              module cleanup at exit.
95
96       -V ,  --version
97              Prints the Python version number of the executable and exits.
98
99       -W argument
100              Warning control.  Python sometimes  prints  warning  message  to
101              sys.stderr.   A  typical warning message has the following form:
102              file:line: category:  message.   By  default,  each  warning  is
103              printed  once for each source line where it occurs.  This option
104              controls how often warnings are printed.   Multiple  -W  options
105              may  be  given; when a warning matches more than one option, the
106              action for the last matching option is  performed.   Invalid  -W
107              options  are ignored (a warning message is printed about invalid
108              options when the first warning is issued).  Warnings can also be
109              controlled  from within a Python program using the warnings mod‐
110              ule.
111
112              The simplest form of argument is one  of  the  following  action
113              strings  (or  a unique abbreviation): ignore to ignore all warn‐
114              ings; default to explicitly request the default behavior (print‐
115              ing  each  warning once per source line); all to print a warning
116              each time it occurs (this may generate many messages if a  warn‐
117              ing  is  triggered  repeatedly for the same source line, such as
118              inside a loop); module to print each warning only the first time
119              it  occurs  in  each module; once to print each warning only the
120              first time it occurs in the program; or error to raise an excep‐
121              tion instead of printing a warning message.
122
123              The   full  form  of  argument  is  action:message:category:mod‐
124              ule:line.  Here, action is as explained above but  only  applies
125              to messages that match the remaining fields.  Empty fields match
126              all values; trailing empty fields may be omitted.   The  message
127              field  matches  the  start  of the warning message printed; this
128              match is case-insensitive.  The category field matches the warn‐
129              ing category.  This must be a class name; the match test whether
130              the actual warning category of the message is a subclass of  the
131              specified  warning category.  The full class name must be given.
132              The module field matches the (fully-qualified) module name; this
133              match  is  case-sensitive.  The line field matches the line num‐
134              ber, where zero matches all line numbers and is thus  equivalent
135              to an omitted line number.
136
137       -X option
138              Set implementation specific option.
139
140       -x     Skip  the  first line of the source.  This is intended for a DOS
141              specific hack only.  Warning: the line numbers in error messages
142              will be off by one!
143

INTERPRETER INTERFACE

145       The interpreter interface resembles that of the UNIX shell: when called
146       with standard input connected to a tty device, it prompts for  commands
147       and  executes  them  until an EOF is read; when called with a file name
148       argument or with a file as standard input,  it  reads  and  executes  a
149       script  from  that  file;  when called with -c command, it executes the
150       Python statement(s) given as command.  Here command may contain  multi‐
151       ple  statements  separated by newlines.  Leading whitespace is signifi‐
152       cant in Python statements!  In non-interactive mode, the  entire  input
153       is parsed before it is executed.
154
155       If  available,  the script name and additional arguments thereafter are
156       passed to the script in the Python variable sys.argv, which is  a  list
157       of  strings (you must first import sys to be able to access it).  If no
158       script name is given, sys.argv[0] is an empty string; if  -c  is  used,
159       sys.argv[0] contains the string '-c'.  Note that options interpreted by
160       the Python interpreter itself are not placed in sys.argv.
161
162       In interactive mode, the primary prompt is  `>>>';  the  second  prompt
163       (which  appears  when a command is not complete) is `...'.  The prompts
164       can be changed by assignment to sys.ps1 or  sys.ps2.   The  interpreter
165       quits  when  it  reads an EOF at a prompt.  When an unhandled exception
166       occurs, a stack trace is printed and control  returns  to  the  primary
167       prompt;  in  non-interactive mode, the interpreter exits after printing
168       the stack trace.  The interrupt  signal  raises  the  KeyboardInterrupt
169       exception;  other  UNIX  signals are not caught (except that SIGPIPE is
170       sometimes ignored, in favor of the IOError exception).  Error  messages
171       are written to stderr.
172

FILES AND DIRECTORIES

174       These are subject to difference depending on local installation conven‐
175       tions; ${prefix}  and  ${exec_prefix}  are  installation-dependent  and
176       should  be  interpreted as for GNU software; they may be the same.  The
177       default for both is /usr/local.
178
179       ${exec_prefix}/bin/python
180              Recommended location of the interpreter.
181
182       ${prefix}/lib/python<version>
183       ${exec_prefix}/lib/python<version>
184              Recommended locations of the directories containing the standard
185              modules.
186
187       ${prefix}/include/python<version>
188       ${exec_prefix}/include/python<version>
189              Recommended  locations of the directories containing the include
190              files needed for developing Python extensions and embedding  the
191              interpreter.
192

ENVIRONMENT VARIABLES

194       PYTHONHOME
195              Change  the  location  of  the  standard  Python  libraries.  By
196              default, the libraries are searched in ${prefix}/lib/python<ver‐
197              sion>  and  ${exec_prefix}/lib/python<version>,  where ${prefix}
198              and ${exec_prefix} are installation-dependent directories,  both
199              defaulting  to  /usr/local.  When $PYTHONHOME is set to a single
200              directory, its value replaces both ${prefix} and ${exec_prefix}.
201              To specify different values for these, set $PYTHONHOME to ${pre‐
202              fix}:${exec_prefix}.
203
204       PYTHONPATH
205              Augments the default search path for module files.   The  format
206              is  the  same  as the shell's $PATH: one or more directory path‐
207              names  separated  by  colons.   Non-existent   directories   are
208              silently  ignored.   The  default  search  path  is installation
209              dependent, but generally begins  with  ${prefix}/lib/python<ver‐
210              sion> (see PYTHONHOME above).  The default search path is always
211              appended to $PYTHONPATH.  If a script  argument  is  given,  the
212              directory containing the script is inserted in the path in front
213              of $PYTHONPATH.  The search path can be manipulated from  within
214              a Python program as the variable sys.path.
215
216       PYTHONSTARTUP
217              If  this  is the name of a readable file, the Python commands in
218              that file are executed before the first prompt is  displayed  in
219              interactive  mode.   The file is executed in the same name space
220              where interactive commands are executed so that objects  defined
221              or  imported  in  it  can  be  used without qualification in the
222              interactive session.  You can also change  the  prompts  sys.ps1
223              and sys.ps2 in this file.
224
225       PYTHONOPTIMIZE
226              If  this is set to a non-empty string it is equivalent to speci‐
227              fying the -O option. If set to an integer, it is  equivalent  to
228              specifying -O multiple times.
229
230       PYTHONDEBUG
231              If  this is set to a non-empty string it is equivalent to speci‐
232              fying the -d option. If set to an integer, it is  equivalent  to
233              specifying -d multiple times.
234
235       PYTHONDONTWRITEBYTECODE
236              If  this is set to a non-empty string it is equivalent to speci‐
237              fying the -B option (don't try to write .py[co] files).
238
239       PYTHONINSPECT
240              If this is set to a non-empty string it is equivalent to  speci‐
241              fying the -i option.
242
243       PYTHONIOENCODING
244              If  this is set before running the interpreter, it overrides the
245              encoding used for stdin/stdout/stderr, in the  syntax  encoding‐
246              name:errorhandler  The errorhandler part is optional and has the
247              same meaning as in str.encode. For stderr, the errorhandler
248               part is ignored; the handler will always be ´backslashreplace´.
249
250       PYTHONNOUSERSITE
251              If this is set to a non-empty string it is equivalent to  speci‐
252              fying  the  -s  option  (Don't  add  the  user site directory to
253              sys.path).
254
255       PYTHONUNBUFFERED
256              If this is set to a non-empty string it is equivalent to  speci‐
257              fying the -u option.
258
259       PYTHONVERBOSE
260              If  this is set to a non-empty string it is equivalent to speci‐
261              fying the -v option. If set to an integer, it is  equivalent  to
262              specifying -v multiple times.
263
264       PYTHONWARNINGS
265              If  this  is set to a comma-separated string it is equivalent to
266              specifying the -W option for each separate value.
267
268       PYTHONHASHSEED
269              If this variable is set to "random", a random value is  used  to
270              seed the hashes of str, bytes and datetime objects.
271
272              If  PYTHONHASHSEED  is  set to an integer value, it is used as a
273              fixed seed for generating the hash() of the types covered by the
274              hash randomization.  Its purpose is to allow repeatable hashing,
275              such as for selftests for the interpreter itself, or to allow  a
276              cluster of python processes to share hash values.
277
278              The   integer   must   be   a   decimal   number  in  the  range
279              [0,4294967295].  Specifying the value 0 will disable  hash  ran‐
280              domization.
281

AUTHOR

283       The Python Software Foundation: https://www.python.org/psf/
284

INTERNET RESOURCES

286       Main website:  https://www.python.org/
287       Documentation:  https://docs.python.org/
288       Developer resources:  https://docs.python.org/devguide/
289       Downloads:  https://www.python.org/downloads/
290       Module repository:  https://pypi.python.org/
291       Newsgroups:  comp.lang.python, comp.lang.python.announce
292

LICENSING

294       Python  is  distributed  under  an  Open  Source license.  See the file
295       "LICENSE" in the Python source distribution for information on terms  &
296       conditions  for  accessing  and  otherwise  using Python and for a DIS‐
297       CLAIMER OF ALL WARRANTIES.
298
299
300
301                                                                     PYTHON(1)
Impressum