PYTHON(1)

πŸ“¦ version 3.6.15, in fedora 43, fedora 44

πŸ’– python(1) β€” the General Commands Manual, but make it a group chat πŸ’–

okay bestie, sit down, hydrate, because we're about to talk about python β€” and not the snake, the whole entire programming language that lives in your General Commands Manual. yes, python(1). she's a legend, she's an icon, and she's about to be explained to you like I'm your smartest friend and you're texting me at 2am. let's go ✨


🌸 NAME 🌸

python β€” an interpreted, interactive, object-oriented programming language. that's the whole vibe check right there. three adjectives, all bangers. πŸπŸ’…


✨ SYNOPSIS ✨

the sacred invocation, exactly as written, do not freestyle it:

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

look at all those little flags. she has so many options because she's that girl. πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

so. python is an interpreted, interactive, object-oriented programming language, and the way it combines remarkable power with very clear syntax?? it's giving main character energy, fr fr. πŸ˜­πŸ’œ

if you want an intro 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 β€” and I quote β€” (perhaps too) much detail. love that for us. those documents can be found via the INTERNET RESOURCES down below (in the later part of this page, bestie, keep scrolling when we get there), and they might be installed on your system too, no cap. πŸ“š

now, Python's basic power can be extended with your own modules written in C or C++ 🫢 β€” and on most systems, those modules may be dynamically loaded. she's also adaptable as an extension language for existing applications. for hints on that, see the internal documentation. iykyk.

and hey β€” you can view documentation for installed Python modules and packages by running the pydoc program. iconic. run it. πŸ‘‘


πŸ’… COMMAND LINE OPTIONS πŸ’…

every single flag, in order, no skips, no skipsies:

  • -B β€” don't write .pyc files on import. see also PYTHONDONTWRITEBYTECODE. she's just not in the mood to leave bytecode lying around, okay? πŸ™ˆ
  • -b β€” issue warnings about str(bytes_instance), str(bytearray_instance) and comparing bytes/bytearray with str. and if you hit her with -bb?? those become errors. dramatic but fair. πŸ’€
  • -c command β€” specify the command to execute (see the next section for the deets). this terminates the option list, so everything after it gets passed as arguments to the command instead. she's done taking notes from you at this point. βœ‹
  • -d β€” turn on parser debugging output. for wizards only, and it depends on compilation options. πŸ§™
  • -E β€” ignore environment variables like PYTHONPATH and PYTHONHOME that modify the behavior of the interpreter. not today, env vars. 🚫
  • -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 -c option is used, enter interactive mode after executing the script or the command. note: it does not read the $PYTHONSTARTUP file. this is lowkey so useful for inspecting global variables or a stack trace when a script raises an exception. forensic queen. πŸ”
  • -I β€” run Python in isolated mode. this also implies -E and -s. in isolated mode, sys.path contains neither the script's directory nor the user's site-packages directory, and all PYTHON* environment variables are ignored too. further restrictions may be imposed to prevent the user from injecting malicious code. she's in her locked-down era. πŸ”’
  • -m module-name β€” searches sys.path for the named module and runs the corresponding .py file as a script. ✨
  • -O β€” remove assert statements and any code conditional on the value of __debug__; also augments the filename for compiled (bytecode) files by adding .opt-1 before the .pyc extension. optimization o'clock. ⚑
  • -OO β€” does -O and also discards docstrings; and it changes the filename for compiled (bytecode) files by adding .opt-2 before the .pyc extension. double the stripping, double the fun. πŸŽ€
  • -q β€” do not print the version and copyright messages. these messages are also suppressed in non-interactive mode anyway. quiet luxury. 🀫
  • -s β€” don't add the user site directory to sys.path. nope. πŸ™…
  • -S β€” disable the import of the module site and the site-dependent manipulations of sys.path that it entails. also disables these manipulations if site is explicitly imported later. so like, forever, basically. πŸ’€
  • -u β€” force the binary I/O layers of stdout and stderr to be unbuffered. important: stdin is always buffered. and the text I/O layer will still be line-buffered. so many layers, so little time. πŸ§…
  • -v β€” print a message each time a module is initialized, showing the place (filename or built-in module) from which it is loaded. give it twice and it prints a message for each file that is checked for when searching for a module. it also provides information on module cleanup at exit. chatty and thorough. πŸ—£οΈ
  • -V, --version β€” prints the Python version number of the executable and exits. give it twice and it prints more information about the build. πŸ‘‘
  • -W argument β€” warning control. here's the situation: Python sometimes prints warning messages to sys.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 -W options may be given; when a warning matches more than one option, the action for the last matching option is performed. invalid -W options 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 the warnings module. 🚨

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.
  • 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, and the match tests whether the actual warning category of the message is a subclass of the specified warning category, so the full class name must be given. the module field matches the (fully-qualified) module name, and 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. short and mysterious, love her. 🎩
  • -x β€” skip the first line of the source. this is intended for a DOS specific hack only. and now the warning, bestie, read it:
⚠️ Warning: the line numbers in error messages will be off by one! 😭

🌈 INTERPRETER INTERFACE 🌈

the interpreter interface resembles that of the UNIX shell, and honestly? the parallels are real:

  • when called with standard input connected to a tty device, it prompts for commands and executes them until an EOF is 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 -c command, it executes the Python statement(s) given as command.

here command may contain multiple statements separated by newlines. and leading whitespace is significant in Python statements! do not touch it, do not breathe on it. πŸ’…

also: in non-interactive mode, the entire input is parsed before it is executed. read it, parse it, then run it. no rush. 🧘

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 β€” and yes, you must first import sys to be able to access it. rules are rules. πŸ“‹

  • 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. sorry babe, those aren't yours. 🫢

in interactive mode, the primary prompt is >>>; the second prompt (which appears when a command is not complete) is .... you can change the prompts by assigning 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 πŸŽ€

quick heads up: 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. πŸ› οΈ

okay that's part one bestie, and there's more coming β€” do not close the chat, we are literally not done ✨

🌈 ENVIRONMENT VARIABLES 🌈

Okay bestie, these are the little shell settings that change how Python wakes up. Set them before you run python and the whole vibe shifts. No cap. ✨


PYTHONHOME 🏠

This one changes the location of the standard Python libraries. By default, Python looks 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. If you set $PYTHONHOME to a single directory, that 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. The format is the same as your shell's $PATH: one or more directory pathnames separated by colons. Non-existent directories are silently ignored β€” no drama, no error. The default search path is installation dependent, but generally begins with ${prefix}/lib/python<version> (see 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 inside 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.

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.

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.

PYTHONDONTWRITEBYTECODE 🚫

If this is set to a non-empty string, it's equivalent to specifying the -B option (don't try to write .pyc files).

PYTHONINSPECT πŸ”

If this is set to a non-empty string, it's equivalent to specifying the -i option.

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Β΄.

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).

PYTHONUNBUFFERED 🌊

If this is set to a non-empty string, it's equivalent to specifying the -u option.

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.

PYTHONWARNINGS ⚠️

If this is set to a comma-separated string, it's equivalent to specifying the -W option for each separate value.

PYTHONHASHSEED 🎲

If this variable is set to "random", a random value is used to seed the hashes of str, bytes and datetime objects.

If PYTHONHASHSEED is set to an integer value, it is 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 disable hash randomization.


πŸ‘‘ AUTHOR πŸ‘‘

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


🌐 INTERNET RESOURCES 🌐


πŸ“œ 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.


Stay iconic, bestie πŸ’– β€” this has been PYTHON(1). The footer's source/version and date are doing their little manpage thing, and we respect it. Go write some main character Python. πŸβœ¨πŸ’…

πŸ“¦ where this page comes from
  • fedora 43: python3.6 3.6.15-49.fc43 Β· LicenseRef-Callaway-Python AND LicenseRef-Callaway-MIT AND Apache-2.0 AND LicenseRef-Callaway-BSD AND ISC AND LicenseRef-Callaway-LGPLv2 AND MPL-2.0 AND (Apache-2.0 OR LicenseRef-Callaway-BSD)
  • fedora 43: python3.6 3.6.15-49.fc43 Β· LicenseRef-Callaway-Python AND LicenseRef-Callaway-MIT AND Apache-2.0 AND LicenseRef-Callaway-BSD AND ISC AND LicenseRef-Callaway-LGPLv2 AND MPL-2.0 AND (Apache-2.0 OR LicenseRef-Callaway-BSD)
  • fedora 43: python3.6 3.6.15-58.fc43 Β· LicenseRef-Callaway-Python AND LicenseRef-Callaway-MIT AND Apache-2.0 AND LicenseRef-Callaway-BSD AND ISC AND LicenseRef-Callaway-LGPLv2 AND MPL-2.0 AND (Apache-2.0 OR LicenseRef-Callaway-BSD)
  • fedora 43: python3.6 3.6.15-58.fc43 Β· LicenseRef-Callaway-Python AND LicenseRef-Callaway-MIT AND Apache-2.0 AND LicenseRef-Callaway-BSD AND ISC AND LicenseRef-Callaway-LGPLv2 AND MPL-2.0 AND (Apache-2.0 OR LicenseRef-Callaway-BSD)
  • fedora 44: python3.6 3.6.15-55.fc44 Β· LicenseRef-Callaway-Python AND LicenseRef-Callaway-MIT AND Apache-2.0 AND LicenseRef-Callaway-BSD AND ISC AND LicenseRef-Callaway-LGPLv2 AND MPL-2.0 AND (Apache-2.0 OR LicenseRef-Callaway-BSD)
  • fedora 44: python3.6 3.6.15-55.fc44 Β· LicenseRef-Callaway-Python AND LicenseRef-Callaway-MIT AND Apache-2.0 AND LicenseRef-Callaway-BSD AND ISC AND LicenseRef-Callaway-LGPLv2 AND MPL-2.0 AND (Apache-2.0 OR LicenseRef-Callaway-BSD)
  • fedora 44: python3.6 3.6.15-58.fc44 Β· LicenseRef-Callaway-Python AND LicenseRef-Callaway-MIT AND Apache-2.0 AND LicenseRef-Callaway-BSD AND ISC AND LicenseRef-Callaway-LGPLv2 AND MPL-2.0 AND (Apache-2.0 OR LicenseRef-Callaway-BSD)
  • fedora 44: python3.6 3.6.15-58.fc44 Β· LicenseRef-Callaway-Python AND LicenseRef-Callaway-MIT AND Apache-2.0 AND LicenseRef-Callaway-BSD AND ISC AND LicenseRef-Callaway-LGPLv2 AND MPL-2.0 AND (Apache-2.0 OR LicenseRef-Callaway-BSD)
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms