-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
Docs: split builtins to their own page from library #156682
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
base: main
Are you sure you want to change the base?
Changes from all commits
a43413e
16703c4
92babb2
c2dbc6e
cb15b64
03f29d1
c28b536
58fa084
45d2eeb
2be0ba5
5f8e102
d871e32
485770d
b16e35b
016ce6b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| .. _builtins-index: | ||
|
|
||
| ############################## | ||
| Python built-ins reference | ||
| ############################## | ||
|
|
||
| Python comes with a number of built-in functions and classes. | ||
|
|
||
| The built-in classes include data types that would normally be considered part | ||
| of the "core" of a language, such as numbers and lists. For these types, the | ||
| Python language core defines the form of literals and places some constraints | ||
| on their semantics, but does not fully define the semantics. | ||
|
|
||
| The built-ins also include functions and exceptions --- objects that can | ||
| be used by all Python code without the need of an :keyword:`import` statement. | ||
| Some of these are defined by the core language, but many are not essential for | ||
| the core semantics and are only described here. | ||
|
|
||
| .. seealso:: | ||
|
|
||
| In addition to the built-ins, Python provides an extensive importable | ||
| standard library, see :ref:`library-index`. | ||
|
|
||
| .. We don't use :numbered: option for the TOC below as it enforces | ||
| numbered sections for the entire builtin docs. If desired, | ||
| :numbered: can be enabled on a per-page basis. | ||
| .. toctree:: | ||
| :maxdepth: 2 | ||
|
|
||
| stdtypes.rst | ||
| constants.rst | ||
| functions.rst | ||
| exceptions.rst | ||
| threadsafety.rst | ||
| time-complexity.rst | ||
|
nedbat marked this conversation as resolved.
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,12 @@ | ||
| .. _library-index: | ||
|
|
||
| ############################### | ||
| The Python Standard Library | ||
| The Python standard library | ||
| ############################### | ||
|
|
||
| While :ref:`reference-index` describes the exact syntax and | ||
| semantics of the Python language, this library reference manual | ||
| semantics of the Python language, and :ref:`builtins-index` describes | ||
| the built-ins, this library reference manual | ||
|
Comment on lines
+8
to
+9
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With this addition of built-ins, it makes sense to rewrite this paragraph. I think it would be preferable to order the paragraph more directly:
|
||
| describes the standard library that is distributed with Python. It also | ||
| describes some of the optional components that are commonly included | ||
| in Python distributions. | ||
|
|
@@ -39,12 +40,6 @@ the `Python Package Index <https://pypi.org>`_. | |
| :maxdepth: 2 | ||
|
|
||
| intro.rst | ||
| functions.rst | ||
| constants.rst | ||
| stdtypes.rst | ||
| exceptions.rst | ||
| threadsafety.rst | ||
| time-complexity.rst | ||
|
|
||
| text.rst | ||
| binary.rst | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,48 +4,34 @@ | |
| Introduction | ||
| ************ | ||
|
|
||
| The "Python library" contains several different kinds of components. | ||
|
|
||
| It contains data types that would normally be considered part of the "core" of a | ||
| language, such as numbers and lists. For these types, the Python language core | ||
| defines the form of literals and places some constraints on their semantics, but | ||
| does not fully define the semantics. (On the other hand, the language core does | ||
| define syntactic properties like the spelling and priorities of operators.) | ||
|
|
||
| The library also contains built-in functions and exceptions --- objects that can | ||
| be used by all Python code without the need of an :keyword:`import` statement. | ||
| Some of these are defined by the core language, but many are not essential for | ||
| the core semantics and are only described here. | ||
|
|
||
| The bulk of the library, however, consists of a collection of modules. There are | ||
| many ways to dissect this collection. Some modules are written in C and built | ||
| in to the Python interpreter; others are written in Python and imported in | ||
| The Python standard library consists of a collection of modules. There are | ||
| many ways to dissect this collection. Some modules are written in C and compiled | ||
| into the Python interpreter; others are written in Python and imported in | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we say that some modules are written in C and compiled to importable modules, or is it confusing at this point? |
||
| source form. Some modules provide interfaces that are highly specific to | ||
| Python, like printing a stack trace; some provide interfaces that are specific | ||
| to particular operating systems, such as access to specific hardware; others | ||
| provide interfaces that are specific to a particular application domain, like | ||
| the World Wide Web. Some modules are available in all versions and ports of | ||
| web development. Some modules are available in all versions and ports of | ||
| Python; others are only available when the underlying system supports or | ||
| requires them; yet others are available only when a particular configuration | ||
| option was chosen at the time when Python was compiled and installed. | ||
|
|
||
| This manual is organized "from the inside out:" it first describes the built-in | ||
| functions, data types and exceptions, and finally the modules, grouped in | ||
| chapters of related modules. | ||
|
|
||
| This means that if you start reading this manual from the start, and skip to the | ||
| If you start reading this manual from the start, and skip to the | ||
| next chapter when you get bored, you will get a reasonable overview of the | ||
| available modules and application areas that are supported by the Python | ||
| library. Of course, you don't *have* to read it like a novel --- you can also | ||
| browse the table of contents (in front of the manual), or look for a specific | ||
| function, module or term in the index (in the back). And finally, if you enjoy | ||
| learning about random subjects, you choose a random page number (see module | ||
| :mod:`random`) and read a section or two. Regardless of the order in which you | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not keep the random module link as an example of a random page? (and/or maybe a hint about a way to make random decision!) Not fully sure what the original intent was here, but as we are in Library Reference and not Tutorial I don’t think the link was bad. Can you say why you removed it? |
||
| read the sections of this manual, it helps to start with chapter | ||
| :ref:`built-in-funcs`, as the remainder of the manual assumes familiarity with | ||
| this material. | ||
| learning about random subjects, you choose a random page | ||
| and read a section or two. Regardless of the order in which you | ||
| read the sections of this manual, it helps to first read | ||
| :ref:`built-in-funcs` in :ref:`builtins-index`, as the remainder of this section | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the second link required, if the first one already brings the reader to the right page? (This reads to me like «Read Section A in Chapter 1», which is needed in books but not hypertext) |
||
| assumes familiarity with this material. | ||
|
|
||
| .. seealso:: | ||
|
|
||
| Let the show begin! | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wasn’t this was harmless and a bit of flair? |
||
| The built-in functions and classes (which can be used without an | ||
| :keyword:`import` statement) are described in :ref:`builtins-index`. | ||
|
|
||
|
|
||
| .. _availability: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,10 +4,11 @@ | |
| The Python Language Reference | ||
| ################################# | ||
|
|
||
| This reference manual describes the syntax and "core semantics" of the | ||
| This reference manual describes the syntax and core semantics of the | ||
| language. It is terse, but attempts to be exact and complete. The semantics of | ||
| non-essential built-in object types and of the built-in functions and modules | ||
| are described in :ref:`library-index`. For an informal introduction to the | ||
| built-in object types and of the built-in functions and modules | ||
|
StanFromIreland marked this conversation as resolved.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe "standard library modules" |
||
| are described in :ref:`builtins-index` and :ref:`library-index`. | ||
| For an informal introduction to the | ||
| language, see :ref:`tutorial-index`. For C or C++ programmers, two additional | ||
| manuals exist: :ref:`extending-index` describes the high-level picture of how to | ||
| write a Python extension module, and the :ref:`c-api-index` describes the | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,7 +80,7 @@ Key ideas | |
| using memoization. | ||
| - If parsing fails completely (no rule succeeds in parsing all the input text), the | ||
| PEG parser doesn't have a concept of "where the | ||
| [`SyntaxError`](https://docs.python.org/3/library/exceptions.html#SyntaxError) is". | ||
| [`SyntaxError`](https://docs.python.org/3/builtins/exceptions.html#SyntaxError) is". | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Noting this (and similar
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be better to leave the old URLs and let the redirects handle it? |
||
|
|
||
|
|
||
| > [!IMPORTANT] | ||
|
|
@@ -654,7 +654,7 @@ is, and it will unwind the stack and report the exception. This means that if a | |
| [rule action](#grammar-actions) raises an exception, all parsing will | ||
| stop at that exact point. This is done to allow to correctly propagate any | ||
| exception set by calling Python's C API functions. This also includes | ||
| [`SyntaxError`](https://docs.python.org/3/library/exceptions.html#SyntaxError) | ||
| [`SyntaxError`](https://docs.python.org/3/builtins/exceptions.html#SyntaxError) | ||
| exceptions and it is the main mechanism the parser uses to report custom syntax | ||
| error messages. | ||
|
|
||
|
|
@@ -715,7 +715,7 @@ acts in two phases: | |
| > When defining invalid rules: | ||
| > | ||
| > - Make sure all custom invalid rules raise | ||
| > [`SyntaxError`](https://docs.python.org/3/library/exceptions.html#SyntaxError) | ||
| > [`SyntaxError`](https://docs.python.org/3/builtins/exceptions.html#SyntaxError) | ||
| > exceptions (or a subclass of it). | ||
| > - Make sure **all** invalid rules start with the `invalid_` prefix to not | ||
| > impact performance of parsing correct Python code. | ||
|
|
@@ -823,7 +823,7 @@ $ python -m pegen python <PATH TO YOUR GRAMMAR FILE> | |
| > Python's grammar (the `Grammar/python.gram` file) is written for the | ||
| > C backend. To experiment, you will need to write a grammar | ||
| > without C-specific parts like actions and the trailer. | ||
| > See [#133560](https://github.com/python/cpython/issues/133560) | ||
| > See [#133560](https://github.com/python/cpython/issues/133560) | ||
| > and [#96424](https://github.com/python/cpython/issues/96424) for more information. | ||
|
|
||
| This will generate a file called `parse.py` in the same directory that you | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.