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

INTERPRETER INTERFACE

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

FILES AND DIRECTORIES

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

ENVIRONMENT VARIABLES

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

AUTHOR

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

INTERNET RESOURCES

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

LICENSING

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