10000 gh-103066: Add links and `help` in site.py constants by davidcaron · Pull Request #103777 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-103066: Add links and help in site.py constants #103777

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Doc/library/constants.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ A small number of constants live in the built-in namespace. They are:
:exc:`SyntaxError`), so they can be considered "true" constants.


.. _site-consts:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The objects above are all non-callable singleton or doubleton instances of their class. (debug is one of False or True). All of the below are callable singleton or doubleton instances of custom classes in _sitebuiltins. I would prefer that 'constants' be replaced by 'objects'/'callables'/'functions'/???, but this is secondary to the issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with your observation, they are not exactly constants. As the title of this section is "Built-in Constants", I won't make any changes, I feel it's a bit out of scope.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would take the opportunity to improve this to say that the site module adds several globals to the built-in namespace


Constants added by the :mod:`site` module
-----------------------------------------

Expand All @@ -97,6 +99,13 @@ should not be used in programs.
(i.e. EOF) to exit", and when called, raise :exc:`SystemExit` with the
specified exit code.

.. data:: help
:noindex:

Object that when printed, prints the message "Type help() for interactive
help, or help(object) for help about object.", and when called,
acts as described :func:`elsewhere <help>`.

.. data:: copyright
credits

Expand Down
5 changes: 3 additions & 2 deletions Doc/library/site.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import can be suppressed using the interpreter's :option:`-S` option.

.. index:: triple: module; search; path

Importing this module will append site-specific paths to the module search path
and add a few builtins, unless :option:`-S` was used. In that case, this module
Importing this module normally appends site-specific paths to the module search path
and adds :ref:`callables <site-consts>`, including :func:`help` to the built-in
namespace. However, Python startup option :option:`-S` blocks this and this module
can be safely imported with no automatic modifications to the module search path
or additions to the builtins. To explicitly trigger the usual site-specific
additions, call the :func:`main` function.
Expand Down
Loading
0