PYTHON(1)
๐ธ PYTHON(1) โ General Commands Manual ๐ธ
okay bestie, buckle up, because this is the page. the python one. the icon, the moment, the whole vibe. ๐
โจ NAME โจ
python โ an interpreted, interactive, object-oriented programming language
๐ฆ SYNOPSIS ๐ฆ
python [ -B ] [ -d ] [ -E ] [ -h ] [ -i ] [ -m module-name ]
[ -O ] [ -OO ] [ -R ] [ -Q argument ] [ -s ] [ -S ] [ -t ] [ -u ]
[ -v ] [ -V ] [ -W argument ] [ -x ] [ -3 ] [ -? ]
[ -c command | script | - ] [ arguments ]
๐ DESCRIPTION ๐
so. Python is an interpreted, interactive, object-oriented programming language that lowkey combines remarkable power with very clear syntax. it's giving "effortlessly powerful," no cap. โจ
if you want an actual intro to programming in Python, go read the Python Tutorial. the Python Library Reference is where the built-in and standard types, constants, functions and modules are documented. and finally the Python Reference Manual describes the syntax and semantics of the core language in (perhaps too) much detail โ like, it truly said "I will explain everything." ๐ญ you can find all these documents via the INTERNET RESOURCES below (and they might already be installed on your system too, check bestie).
Python's basic power can be extended with your own modules written in C or C++. on most systems those modules can be dynamically loaded. Python is also adaptable as an extension language for existing applications โ see the internal documentation for hints. ๐ซถ
and ooh, documentation for installed Python modules and packages can be viewed by running the pydoc program. iconic.
๐ COMMAND LINE OPTIONS ๐
-Bโ don't write.py[co]files on import. see alsoPYTHONDONTWRITEBYTECODE. (no extra bytecode crumbs left behind, we love a clean room ๐ )-ccommand โ specify the command to execute (peep the next section for the deets). this terminates the option list โ meaning everything after it gets passed as arguments to the command. periodt.-dโ turn on parser debugging output. (for wizards only ๐ฎ, and it depends on compilation options.)-Eโ ignore environment variables likePYTHONPATHandPYTHONHOMEthat modify the behavior of the interpreter.-h,-?,--helpโ prints the usage for the interpreter executable and exits. the classic "help me" trio.-iโ when a script is passed as first argument or the-coption is used, enter interactive mode after executing the script or the command. it does not read the$PYTHONSTARTUPfile. this is so useful for inspecting global variables or a stack trace when a script raises an exception โ like peeking behind the curtain after the drama. ๐-mmodule-name โ searchessys.pathfor the named module and runs the corresponding.pyfile as a script.-Oโ turn on basic optimizations. this changes the filename extension for compiled (bytecode) files from.pycto.pyo. given twice, it causes docstrings to be discarded. ๐ญ (the docstrings!!)-OOโ discard docstrings in addition to the-Ooptimizations.-Rโ turn on "hash randomization", so that thehash()values ofstr,bytesanddatetimeobjects are "salted" with an unpredictable pseudo-random value. although they remain constant within an individual Python process, they are not predictable between repeated invocations of Python.
this is intended to provide protection against a denial of service caused by carefully-chosen inputs that exploit the worst case performance of a dict construction, O(n^2) complexity. see http://www.ocert.org/advisories/ocert-2011-003.html for details.
-Qargument โ division control; see PEP 238. the argument must be one of:"old"โ the default,int/intandlong/longreturn anintorlong"new"โ new division semantics, i.e.int/intandlong/longreturns afloat"warn"โ old division semantics with a warning forint/intandlong/long"warnall"โ old division semantics with a warning for all use of the division operator
for a use of "warnall", see the Tools/scripts/fixdiv.py script.
-sโ don't add user site directory tosys.path.-Sโ disable the import of the modulesiteand the site-dependent manipulations ofsys.paththat it entails.-tโ issue a warning when a source file mixes tabs and spaces for indentation in a way that makes it depend on the worth of a tab expressed in spaces. issue an error when the option is given twice.-uโ forcestdin,stdoutandstderrto be totally unbuffered. on systems where it matters, also putstdin,stdoutandstderrin binary mode. note that there is internal buffering inxreadlines(),readlines()and file-object iterators ("for line in sys.stdin") which is not influenced by this option. to work around this, you will want to use"sys.stdin.readline()"inside a"while 1:"loop.-vโ print a message each time a module is initialized, showing the place (filename or built-in module) from which it is loaded. when given twice, print a message for each file that is checked for when searching for a module. also provides information on module cleanup at exit. (chatty king ๐ฌ)-V,--versionโ prints the Python version number of the executable and exits.-Wargument โ warning control. Python sometimes prints warning message tosys.stderr. a typical warning message has the following form:file:line: category: message. by default, each warning is printed once for each source line where it occurs. this option controls how often warnings are printed. multiple-Woptions may be given; when a warning matches more than one option, the action for the last matching option is performed. invalid-Woptions are ignored (a warning message is printed about invalid options when the first warning is issued). warnings can also be controlled from within a Python program using thewarningsmodule.
the simplest form of argument is one of the following action strings (or a unique abbreviation):
ignoreโ to ignore all warningsdefaultโ to explicitly request the default behavior (printing each warning once per source line)allโ to print a warning each time it occurs (this may generate many messages if a warning is triggered repeatedly for the same source line, such as inside a loop)moduleโ to print each warning only the first time it occurs in each moduleonceโ to print each warning only the first time it occurs in the programerrorโ to raise an exception instead of printing a warning message
the full form of argument is action:message:category:module:line. here, action is as explained above but only applies to messages that match the remaining fields. empty fields match all values; trailing empty fields may be omitted. the message field matches the start of the warning message printed; this match is case-insensitive. the category field matches the warning category. this must be a class name; the match test whether the actual warning category of the message is a subclass of the specified warning category. the full class name must be given. the module field matches the (fully-qualified) module name; this match is case-sensitive. the line field matches the line number, where zero matches all line numbers and is thus equivalent to an omitted line number.
-xโ skip the first line of the source. this is intended for a DOS specific hack only. > Warning: the line numbers in error messages will be off by one! โ ๏ธ-3โ warn about Python 3.x incompatibilities that2to3cannot trivially fix.
๐ INTERPRETER INTERFACE ๐
the interpreter interface resembles that of the UNIX shell, which is honestly such a serve. here's the tea:
- when called with standard input connected to a
ttydevice, it prompts for commands and executes them until anEOFis read; - when called with a file name argument or with a file as standard input, it reads and executes a script from that file;
- when called with
-ccommand, it executes the Python statement(s) given as command.
here, command may contain multiple statements separated by newlines. leading whitespace is significant in Python statements! in non-interactive mode, the entire input is parsed before it is executed.
if available, the script name and additional arguments thereafter are passed to the script in the Python variable sys.argv, which is a list of strings (you must first import sys to be able to access it). if no script name is given, sys.argv[0] is an empty string; if -c is used, sys.argv[0] contains the string '-c'. note that options interpreted by the Python interpreter itself are not placed in sys.argv.
in interactive mode, the primary prompt is >>>; the second prompt (which appears when a command is not complete) is .... the prompts can be changed by assignment to sys.ps1 or sys.ps2. the interpreter quits when it reads an EOF at a prompt. when an unhandled exception occurs, a stack trace is printed and control returns to the primary prompt; in non-interactive mode, the interpreter exits after printing the stack trace. the interrupt signal raises the KeyboardInterrupt exception; other UNIX signals are not caught (except that SIGPIPE is sometimes ignored, in favor of the IOError exception). error messages are written to stderr.
๐ FILES AND DIRECTORIES ๐
these are subject to difference depending on local installation conventions; ${prefix} and ${exec_prefix} are installation-dependent and should be interpreted as for GNU software; they may be the same. on Debian GNU/{Hurd,Linux} the default for both is /usr.
${exec_prefix}/bin/pythonโ recommended location of the interpreter.${prefix}/lib/python<version>${exec_prefix}/lib/python<version>โ recommended locations of the directories containing the standard modules.${prefix}/include/python<version>${exec_prefix}/include/python<version>โ recommended locations of the directories containing the include files needed for developing Python extensions and embedding the interpreter.~/.pythonrc.pyโ user-specific initialization file loaded by theusermodule; not used by default or by most applications. (it's the shy one, it only shows up if you invite it ๐ซถ)
...and bestie, that's not even the whole page โ more parts are coming, so stay tuned ๐
๐ฟ ENVIRONMENT VARIABLES ๐ฟ
okay bestie, these are the little environment switches that change Python's whole personality before it even boots up. no cap, they're giving backstage pass energy. ๐
PYTHONHOME
This one changes where the standard Python libraries live. by default, Python looks in ${prefix}/lib/python<version> and ${exec_prefix}/lib/python<version> โ and ${prefix} and ${exec_prefix} are installation-dependent directories, both defaulting to /usr/local. when $PYTHONHOME is set to a single directory, its value replaces both ${prefix} and ${exec_prefix}. wanna give them different values? set $PYTHONHOME to ${prefix}:${exec_prefix}. periodt. ๐
PYTHONPATH
This augments the default search path for module files. format? same as the shell's $PATH: one or more directory pathnames separated by colons. non-existent directories are silently ignored (so rude but okay). the default search path is installation dependent, but generally begins with ${prefix}/lib/python<version> (peep PYTHONHOME above). the default search path is always appended to $PYTHONPATH. if a script argument is given, the directory containing the script is inserted in the path in front of $PYTHONPATH. you can also manipulate the search path from within a Python program as the variable sys.path. ๐
PYTHONSTARTUP
If this is the name of a readable file, the Python commands in that file are executed before the first prompt is displayed in interactive mode. the file is executed in the same name space where interactive commands are executed, so objects defined or imported in it can be used without qualification in the interactive session. you can also change the prompts sys.ps1 and sys.ps2 in this file. it's giving pre-game ritual. ๐
PYTHONY2K
Set this to a non-empty string to cause the time module to require dates specified as strings to include 4-digit years. otherwise, 2-digit years are converted based on rules described in the time module documentation. y2k but make it Python. ๐ฐ๏ธ
PYTHONOPTIMIZE
If this is set to a non-empty string, it's equivalent to specifying the -O option. if set to an integer, it's equivalent to specifying -O multiple times. optimization queen. โจ
PYTHONDEBUG
If this is set to a non-empty string, it's equivalent to specifying the -d option. if set to an integer, it's equivalent to specifying -d multiple times. debug mode activated, bestie. ๐
PYTHONDONTWRITEBYTECODE
If this is set to a non-empty string, it's equivalent to specifying the -B option (don't try to write .py[co] files). no bytecode leftovers, we love a clean girl. ๐งผ
PYTHONINSPECT
If this is set to a non-empty string, it's equivalent to specifying the -i option. inspect away. ๐
PYTHONIOENCODING
If this is set before running the interpreter, it overrides the encoding used for stdin/stdout/stderr, in the syntax encodingname:errorhandler. the errorhandler part is optional and has the same meaning as in str.encode. for stderr, the errorhandler part is ignored; the handler will always be ยดbackslashreplaceยด. encoding drama handled. ๐
PYTHONNOUSERSITE
If this is set to a non-empty string, it's equivalent to specifying the -s option (Don't add the user site directory to sys.path). no user site, just vibes. ๐ซ
PYTHONUNBUFFERED
If this is set to a non-empty string, it's equivalent to specifying the -u option. unbuffered and unbothered. ๐
PYTHONVERBOSE
If this is set to a non-empty string, it's equivalent to specifying the -v option. if set to an integer, it's equivalent to specifying -v multiple times. verbose? more like yappable. ๐ฃ๏ธ
PYTHONWARNINGS
If this is set to a comma-separated string, it's equivalent to specifying the -W option for each separate value. warnings but make it a whole list. โ ๏ธ
PYTHONHASHSEED
If this variable is set to "random", the effect is the same as specifying the -R option: a random value is used to seed the hashes of str, bytes and datetime objects.
If PYTHONHASHSEED is set to an integer value, it's used as a fixed seed for generating the hash() of the types covered by the hash randomization. its purpose is to allow repeatable hashing, such as for selftests for the interpreter itself, or to allow a cluster of python processes to share hash values.
The integer must be a decimal number in the range [0,4294967295]. specifying the value 0 will lead to the same hash values as when hash randomization is disabled. hash girl summer. ๐ข
๐ AUTHOR ๐
The Python Software Foundation: https://www.python.org/psf/
they literally made Python. legends only. ๐ซถ
๐ INTERNET RESOURCES ๐
- Main website: https://www.python.org/
- Documentation: file:///usr/share/doc/python2.7/html/index.html (python-doc package) or https://docs.python.org/2/
- Developer resources: https://docs.python.org/devguide/
- Downloads: https://www.python.org/downloads/
- Module repository: https://pypi.python.org/
- Newsgroups: comp.lang.python, comp.lang.python.announce
go touch some docs, bestie. ๐โจ
๐ LICENSING ๐
Python is distributed under an Open Source license. see the file "LICENSE" in the Python source distribution for information on terms & conditions for accessing and otherwise using Python and for a DISCLAIMER OF ALL WARRANTIES.
tl;dr: open source, but read the LICENSE for the legal tea. ๐ต
That's the whole PYTHON(1) manual, bestie โ source/version/date are in the footer, and they're iconic. This was the Python 2.7-era manpage (peep the python2.7 docs path), and the footer said PYTHON(1). slay, you made it to the end. ๐
๐โจ
๐ฆ where this page comes from
- ubuntu jammy: python2.7-minimal 2.7.18-13ubuntu1
- ubuntu jammy: python2.7-minimal 2.7.18-13ubuntu1.5
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms