For Wizards Only

by stink - on Aug 10, 2021 10:15pm to programming python wizard comments(0)
I recently rode in an airplane for 10 hours in a row with no Internet - the perfect time to read man pages! I decided to read the whole Python man page and here are the interesting tidbits that I found:

Okay so you can extend the language with C/C++ modules. This is fairly standard for languages but cool nonetheless.

There is a -c command line option that allows one to execute a "string" of Python like this:

python -c "print('hello')"

But it seems like this -c option has some limitations and people often use a different method to execute a string of Python.

There is a -d option that turns on parser debugging output. In parentheses it says that this command is "for wizards only". Hmm, I wonder who wrote that?

There are three command line options that one can give once or twice. -O turns on optimizations and -OO also removes docstrings. -t issues a warning if there are spaces and tabs and -tt issues an error if there are spaces and tabs. -v will print a message when a module is initialized and -vv will also print all files that are searched for modules.

Python has a very customizable warnings system. Typically one will only specify an "action" like "ignore" or "default" when doing warning control. However, there are four additional layers that you can specify on top of action and the full format looks like:

action:message:category:module:line

There is a -x command line option that skips the first line of code. It says this is for a DOS hack (lol).

One can change the >>> and ... prompts by setting sys.ps1 and sys.ps2.

There is a PYTHONSTARTUP environment variable. If this points to a readable file then the Python commands in it are executed before the interactive prompt displays.

There are a lot of environment variables that do the same thing as a command line option.
Some comments may be hidden. Show all.
no comments yet