PYTHON(1)
π PYTHON(1) π
General Commands Manual β yes bestie, you clicked on the big one. buckle up π
β¨ NAME β¨
python β an interpreted, interactive, object-oriented programming language πβ¨
π¦ SYNOPSIS π¦
python [ -B ] [ -b ] [ -d ] [ -E ] [ -h ] [ -i ] [ -I ]
[ -m module-name ] [ -q ] [ -O ] [ -OO ] [ -s ] [ -S ] [ -u ]
[ -v ] [ -V ] [ -W argument ] [ -x ] [ [ -X option ] -? ]
[ --check-hash-based-pycs default | always | never ]
[ -c command | script | - ] [ arguments ]
π DESCRIPTION π
okay so Python is an interpreted, interactive, object-oriented programming language that literally combines remarkable power with very clear syntax. it's giving "I can do anything AND you can actually read me" π . wanna get introduced to programming in Python? go read the Python Tutorial. the Python Library Reference is where all the built-in and standard types, constants, functions and modules get documented. and finally the Python Reference Manual describes the syntax and semantics of the core language in (perhaps too) much detail π. (you can find all of these via the INTERNET RESOURCES down below, and they might already be installed on your system too, no cap.)
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 π«Ά
documentation for installed Python modules and packages can be viewed by running the pydoc program. iconic.
π COMMAND LINE OPTIONS π
-Bβ don't write.pycfiles on import. see alsoPYTHONDONTWRITEBYTECODEπΎ-bβ issue warnings aboutstr(bytes_instance),str(bytearray_instance)and comparingbytes/bytearraywithstr. (-bb: issue errors) β οΈ-c commandβ specify the command to execute (see next section). this terminates the option list β everything after it gets passed as arguments to the command, fr fr.--check-hash-based-pycs modeβ configure how Python evaluates the up-to-dateness of hash-based.pycfiles.-dβ turn on parser debugging output (for experts 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 bestie" move.-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 can be useful to inspect global variables or a stack trace when a script raises an exception π-Iβ run Python in isolated mode. this also implies-Eand-s. in isolated modesys.pathcontains neither the script's directory nor the user's site-packages directory. allPYTHON*environment variables are ignored, too. further restrictions may be imposed to prevent the user from injecting malicious code π‘οΈ-m module-nameβ searchessys.pathfor the named module and runs the corresponding.pyfile as a script.-Oβ removeassertstatements and any code conditional on the value of__debug__; augment the filename for compiled (bytecode) files by adding.opt-1before the.pycextension.-OOβ do-Oand also discard docstrings; change the filename for compiled (bytecode) files by adding.opt-2before the.pycextension. bye bye docstrings π-qβ do not print the version and copyright messages. these messages are also suppressed in non-interactive mode. quiet queen behavior π€«-sβ don't add user site directory tosys.path.-Sβ disable the import of the modulesiteand the site-dependent manipulations ofsys.paththat it entails. also disable these manipulations ifsiteis explicitly imported later.-uβ force thestdoutandstderrstreams to be unbuffered. this option has no effect on thestdinstream.-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. it's giving β¨full transparencyβ¨-V,--versionβ prints the Python version number of the executable and exits. when given twice, print more information about the build.-W argumentβ warning control. Python sometimes prints warning messages 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 warnings; default 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 module; once to print each warning only the first time it occurs in the program; or error 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 tests 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 optionβ set implementation specific option. the following options are available:-X faulthandler: enablefaulthandler-X showrefcount: output the total reference count and number of used memory blocks when the program finishes or after each statement in the interactive interpreter. this only works on debug builds-X tracemalloc: start tracing Python memory allocations using thetracemallocmodule. by default, only the most recent frame is stored in a traceback of a trace. use-X tracemalloc=NFRAMEto start tracing with a traceback limit ofNFRAMEframes-X importtime: show how long each import takes. it shows module name, cumulative time (including nested imports) and self time (excluding nested imports). note that its output may be broken in multi-threaded application. typical usage ispython3 -X importtime -c 'import asyncio'-X dev: enable CPython's "development mode", introducing additional runtime checks which are too expensive to be enabled by default. it will not be more verbose than the default if the code is correct: new warnings are only emitted when an issue is detected. effect of the developer mode:- add default warning filter, as
-W default - install debug hooks on memory allocators: see the
PyMem_SetupDebugHooks()C function - enable the
faulthandlermodule to dump the Python traceback on a crash - enable
asynciodebug mode - set the
dev_modeattribute ofsys.flagstoTrue io.IOBasedestructor logsclose()exceptions
- add default warning filter, as
-X utf8: enable UTF-8 mode for operating system interfaces, overriding the default locale-aware mode.-X utf8=0explicitly disables UTF-8 mode (even when it would otherwise activate automatically). seePYTHONUTF8for more details π-X pycache_prefix=PATH: enable writing.pycfiles to a parallel tree rooted at the given directory instead of to the code tree.-X int_max_str_digits=number: limit the size ofint<->strconversions. this helps avoid denial of service attacks when parsing untrusted data. the default issys.int_info.default_max_str_digits.0disables. π
-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! π±
π INTERPRETER INTERFACE π
okay so the interpreter interface is giving UNIX shell energy, fr fr. here's the vibe:
- when it's called with standard input connected to a tty device, it prompts for commands and executes them until it reads an EOF, bestie.
- when it's called with a file name argument or with a file as standard input, it reads and executes a script from that file.
- when it's called with
-ccommand, it executes the Python statement(s) given as command. and yes,commandmay contain multiple statements separated by newlines.
Leading whitespace is significant in Python statements! do not play with it. π
In non-interactive mode, the entire input is parsed before it is executed. periodt.
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. no cap.
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. The default for both is /usr/local. π
${exec_prefix}/bin/pythonβ recommended location of the interpreter. π${prefix}/lib/python<version>and${exec_prefix}/lib/python<version>β recommended locations of the directories containing the standard modules. β¨${prefix}/include/python<version>and${exec_prefix}/include/python<version>β recommended locations of the directories containing the include files needed for developing Python extensions and embedding the interpreter. π¦
πΈ ENVIRONMENT VARIABLES πΈ
PYTHONHOMEβ change the location of the standard Python libraries. By default, the libraries are searched in${prefix}/lib/python<version>and${exec_prefix}/lib/python<version>, where${prefix}and${exec_prefix}are installation-dependent directories, both defaulting to/usr/local. When$PYTHONHOMEis set to a single directory, its value replaces both${prefix}and${exec_prefix}. To specify different values for these, set$PYTHONHOMEto${prefix}:${exec_prefix}. πPYTHONPATHβ augments the default search path for module files. The format is the same as the shell's$PATH: one or more directory pathnames separated by colons. Non-existent directories are silently ignored. The default search path is installation dependent, but generally begins with${prefix}/lib/python<version>(seePYTHONHOMEabove). 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. The search path can be manipulated from within a Python program as the variablesys.path. π£οΈPYTHONPLATLIBDIRβ overridesys.platlibdir. π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 that objects defined or imported in it can be used without qualification in the interactive session. You can also change the promptssys.ps1andsys.ps2in this file. β¨PYTHONOPTIMIZEβ if this is set to a non-empty string it is equivalent to specifying the-Ooption. If set to an integer, it is equivalent to specifying-Omultiple times. π₯PYTHONDEBUGβ if this is set to a non-empty string it is equivalent to specifying the-doption. If set to an integer, it is equivalent to specifying-dmultiple times. πPYTHONDONTWRITEBYTECODEβ if this is set to a non-empty string it is equivalent to specifying the-Boption (don't try to write.pycfiles). π«PYTHONINSPECTβ if this is set to a non-empty string it is equivalent to specifying the-ioption. πPYTHONIOENCODINGβ if this is set before running the interpreter, it overrides the encoding used for stdin/stdout/stderr, in the syntaxencodingname:errorhandler. Theerrorhandlerpart is optional and has the same meaning as instr.encode. For stderr, theerrorhandlerpart is ignored; the handler will always beΒ΄backslashreplaceΒ΄. π€PYTHONNOUSERSITEβ if this is set to a non-empty string it is equivalent to specifying the-soption (Don't add the user site directory tosys.path). πPYTHONUNBUFFEREDβ if this is set to a non-empty string it is equivalent to specifying the-uoption. πPYTHONVERBOSEβ if this is set to a non-empty string it is equivalent to specifying the-voption. If set to an integer, it is equivalent to specifying-vmultiple times. π£οΈPYTHONWARNINGSβ if this is set to a comma-separated string it is equivalent to specifying the-Woption for each separate value. β οΈPYTHONHASHSEEDβ if this variable is set to"random", a random value is used to seed the hashes ofstrandbytesobjects. IfPYTHONHASHSEEDis set to an integer value, it is used as a fixed seed for generating thehash()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 value0will disable hash randomization. π’PYTHONINTMAXSTRDIGITSβ limit the maximum digit characters in an int value when converting from a string and when converting an int back to a str. A value of0disables the limit. Conversions to or from bases2,4,8,16, and32are never limited. π’PYTHONMALLOCβ set the Python memory allocators and/or install debug hooks. The available memory allocators aremallocandpymalloc. The available debug hooks aredebug,malloc_debug, andpymalloc_debug. When Python is compiled in debug mode, the default ispymalloc_debugand the debug hooks are automatically used. Otherwise, the default ispymalloc. π§PYTHONMALLOCSTATSβ if set to a non-empty string, Python will print statistics of thepymallocmemory allocator every time a newpymallocobject arena is created, and on shutdown. This variable is ignored if the$PYTHONMALLOCenvironment variable is used to force themalloc(3)allocator of the C library, or if Python is configured withoutpymallocsupport. πPYTHONASYNCIODEBUGβ if this environment variable is set to a non-empty string, enable the debug mode of theasynciomodule. πPYTHONTRACEMALLOCβ if this environment variable is set to a non-empty string, start tracing Python memory allocations using thetracemallocmodule. The value of the variable is the maximum number of frames stored in a traceback of a trace. For example,PYTHONTRACEMALLOC=1stores only the most recent frame. π§΅PYTHONFAULTHANDLERβ if this environment variable is set to a non-empty string,faulthandler.enable()is called at startup: install a handler forSIGSEGV,SIGFPE,SIGABRT,SIGBUSandSIGILLsignals to dump the Python traceback. This is equivalent to the-X faulthandleroption. π₯PYTHONEXECUTABLEβ if this environment variable is set,sys.argv[0]will be set to its value instead of the value got through the C runtime. Only works on Mac OS X. πPYTHONUSERBASEβ defines the user base directory, which is used to compute the path of the usersite-packagesdirectory and Distutils installation paths forpython setup.py install --user. π¦PYTHONPROFILEIMPORTTIMEβ if this environment variable is set to a non-empty string, Python will show how long each import takes. This is exactly equivalent to setting-X importtimeon the command line. β±οΈPYTHONBREAKPOINTβ if this environment variable is set to0, it disables the default debugger. It can be set to the callable of your debugger of choice. π
π οΈ Debug-mode variables π οΈ
Setting these variables only has an effect in a debug build of Python, that is, if Python was configured with the --with-pydebug build option.
PYTHONTHREADDEBUGβ if this environment variable is set, Python will print threading debug info. π§΅PYTHONDUMPREFSβ if this environment variable is set, Python will dump objects and reference counts still alive after shutting down the interpreter. ποΈ
π AUTHOR π
The Python Software Foundation: https://www.python.org/psf/ π
π INTERNET RESOURCES π
- Main website:
https://www.python.org/ - Documentation:
https://docs.python.org/ - Developer resources:
https://devguide.python.org/ - Downloads:
https://www.python.org/downloads/ - Module repository:
https://pypi.org/ - Newsgroups:
comp.lang.python,comp.lang.python.announce
π 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.
catch you later, bestie β this was PYTHON(1), with the source/version and date chillin' in the footer. π
β¨
π¦ where this page comes from
- centos-stream 9: python3 3.9.25-10.el9 Β· Python
- centos-stream 9: python3 3.9.25-10.el9 Β· Python
- fedora 43: python3.9 3.9.23-2.fc43 Β· Python
- fedora 43: python3.9 3.9.23-2.fc43 Β· Python
- fedora 43: python3.9 3.9.25-11.fc43 Β· Python-2.0.1
- fedora 43: python3.9 3.9.25-11.fc43 Β· Python-2.0.1
- fedora 44: python3.9 3.9.25-11.fc44 Β· Python-2.0.1
- fedora 44: python3.9 3.9.25-11.fc44 Β· Python-2.0.1
- fedora 44: python3.9 3.9.25-6.fc44 Β· Python
- fedora 44: python3.9 3.9.25-6.fc44 Β· Python
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms