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 .pyc files on import. See also PYTHONDONTWRITEBYTE‐
35              CODE.
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     Remove  assert  statements and any code conditional on the value
72              of __debug__; augment the filename for compiled (bytecode) files
73              by adding .opt-1 before the .pyc extension.
74
75       -OO    Do  -O and also discard docstrings; change the filename for com‐
76              piled (bytecode) files by adding .opt-2 before the  .pyc  exten‐
77              sion.
78
79       -q     Do  not print the version and copyright messages. These messages
80              are also suppressed in non-interactive mode.
81
82       -s     Don't add user site directory to sys.path.
83
84       -S     Disable the import of the module  site  and  the  site-dependent
85              manipulations  of  sys.path that it entails.  Also disable these
86              manipulations if site is explicitly imported later.
87
88       -u     Force  the  binary  I/O  layers  of  stdout  and  stderr  to  be
89              unbuffered.   stdin is always buffered.  The text I/O layer will
90              still be line-buffered.
91
92       -v     Print a message each time a module is initialized,  showing  the
93              place  (filename  or  built-in  module) from which it is loaded.
94              When given twice, print a message for each file that is  checked
95              for  when  searching for a module.  Also provides information on
96              module cleanup at exit.
97
98       -V ,  --version
99              Prints the Python version number of the  executable  and  exits.
100              When given twice, print more information about the build.
101
102       -W argument
103              Warning  control.   Python  sometimes  prints warning message to
104              sys.stderr.  A typical warning message has the  following  form:
105              file:line:  category:  message.   By  default,  each  warning is
106              printed once for each source line where it occurs.  This  option
107              controls  how  often  warnings are printed.  Multiple -W options
108              may be given; when a warning matches more than one  option,  the
109              action  for  the  last matching option is performed.  Invalid -W
110              options are ignored (a warning message is printed about  invalid
111              options when the first warning is issued).  Warnings can also be
112              controlled from within a Python program using the warnings  mod‐
113              ule.
114
115              The  simplest  form  of  argument is one of the following action
116              strings (or a unique abbreviation): ignore to ignore  all  warn‐
117              ings; default to explicitly request the default behavior (print‐
118              ing each warning once per source line); all to print  a  warning
119              each  time it occurs (this may generate many messages if a warn‐
120              ing is triggered repeatedly for the same source  line,  such  as
121              inside a loop); module to print each warning only the first time
122              it occurs in each module; once to print each  warning  only  the
123              first time it occurs in the program; or error to raise an excep‐
124              tion instead of printing a warning message.
125
126              The  full  form  of  argument  is   action:message:category:mod‐
127              ule:line.   Here,  action is as explained above but only applies
128              to messages that match the remaining fields.  Empty fields match
129              all  values;  trailing empty fields may be omitted.  The message
130              field matches the start of the  warning  message  printed;  this
131              match is case-insensitive.  The category field matches the warn‐
132              ing category.  This must be a class name; the match test whether
133              the  actual warning category of the message is a subclass of the
134              specified warning category.  The full class name must be  given.
135              The module field matches the (fully-qualified) module name; this
136              match is case-sensitive.  The line field matches the  line  num‐
137              ber,  where zero matches all line numbers and is thus equivalent
138              to an omitted line number.
139
140       -X option
141              Set implementation specific option.
142
143       -x     Skip the first line of the source.  This is intended for  a  DOS
144              specific hack only.  Warning: the line numbers in error messages
145              will be off by one!
146

INTERPRETER INTERFACE

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

FILES AND DIRECTORIES

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

ENVIRONMENT VARIABLES

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

AUTHOR

286       The Python Software Foundation: https://www.python.org/psf/
287

INTERNET RESOURCES

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

LICENSING

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