Commit graph

215 commits

Author SHA1 Message Date
Petr Viktorin
777159fa31
gh-135676: Lexical analysis: Reword String literals and related sections (GH-135942)
Co-authored-by: Blaise Pabon <blaise@gmail.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-07-23 15:57:54 +00:00
Connor Denihan
0d76dccc3b
gh-135110: Fix misleading generator.close() documentation (GH-135152)
Some checks are pending
Tests / (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Undefined behavior sanitizer (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
mypy / Run mypy on Lib/_pyrepl (push) Waiting to run
mypy / Run mypy on Lib/test/libregrtest (push) Waiting to run
mypy / Run mypy on Lib/tomllib (push) Waiting to run
mypy / Run mypy on Tools/build (push) Waiting to run
mypy / Run mypy on Tools/cases_generator (push) Waiting to run
mypy / Run mypy on Tools/clinic (push) Waiting to run
mypy / Run mypy on Tools/jit (push) Waiting to run
mypy / Run mypy on Tools/peg_generator (push) Waiting to run
The documentation incorrectly stated that generator.close() 'raises' a
GeneratorExit exception. This was misleading because the method doesn't
raise the exception to the caller - it sends the exception internally
to the generator and returns None.
2025-06-26 09:27:25 -04:00
HarryLHW
d2154912b3
Docs: Add cross-reference for positional_item in the calls productionlist (GH-129977)
Add missing hyperlink for `positional_item`
2025-06-25 10:24:58 -04:00
Petr Viktorin
21f3d15534
gh-135676: lexical analysis: Improve section on Numeric literals (GH-134850) 2025-06-18 16:34:18 +02:00
Serhiy Storchaka
8979d3afe3
gh-135171: Update documentation for the generator expression (GH-135351)
* gh-135171: Update documentation for the generator expression

Document that the iterator for the leftmost "for" clause is created
immediately.

* Update Doc/reference/expressions.rst

Co-authored-by: Brian Skinn <brian.skinn@gmail.com>

---------

Co-authored-by: Brian Skinn <brian.skinn@gmail.com>
2025-06-14 17:32:44 -07:00
Yash Vijay
4eacf3883d
gh-134026: Fix grammar description of for statement (GH-134034) 2025-05-21 16:09:28 +02:00
sobolevn
5ec4bf86b7
gh-121970: Replace .. coroutine{method,function} with :async: (#130448)
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
2025-02-22 17:54:43 +00:00
Sergey B Kirpichev
987311d42e
gh-69639: Add mixed-mode rules for complex arithmetic (C-like) (GH-124829)
"Generally, mixed-mode arithmetic combining real and complex variables should
be performed directly, not by first coercing the real to complex, lest the sign
of zero be rendered uninformative; the same goes for combinations of pure
imaginary quantities with complex variables." (c) Kahan, W: Branch cuts for
complex elementary functions.

This patch implements mixed-mode arithmetic rules, combining real and
complex variables as specified by C standards since C99 (in particular,
there is no special version for the true division with real lhs
operand).  Most C compilers implementing C99+ Annex G have only these
special rules (without support for imaginary type, which is going to be
deprecated in C2y).
2024-11-26 17:57:39 +02:00
John Marshall
e0692f1165
Document that return-less user-defined functions return None (#126769)
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
2024-11-14 07:47:24 +00:00
Emily Morehouse
447a15190d
gh-125072: Add label for assignment expressions; update tracked section for assignment expression topic (#125074) 2024-10-07 22:51:14 +00:00
Emily Morehouse
626668912f
gh-81263: Add assignment expressions to help (#124641)
* Add assignment expression (:=) to `help`

* Update index for Assignment Expressions to include pair of `assignment; expression`
2024-09-27 13:59:26 -07:00
Matthew Rahtz
7d3497f617
gh-115528: Update language reference for PEP 646 (#121181)
To recap: the objective is to make starred expressions valid in `subscription`,
which is used for generics: `Generic[...]`, `list[...]`, etc.

What _is_ gramatically valid in such contexts? Seemingly any of the following.
(At least, none of the following throw `SyntaxError` in a 3.12.3 REPL.)

    Generic[x]
    Generic[*x]
    Generic[*x, y]
    Generic[y, *x]
    Generic[x := 1]
    Generic[x := 1, y := 2]

So introducting

    flexible_expression: expression | assignment_expression | starred_item

end then switching `subscription` to use `flexible_expression` sorts that.

But then we need to field `yield` - for which any of the following are
apparently valid:

    yield x
    yield x,
    yield x, y
    yield *x,
    yield *x, *y

Introducing a separate `yield_list` is the simplest way I've been figure out to
do this - separating out the special case of `starred_item ,`.



Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-09-26 12:35:17 -07:00
Alex Waygood
0d9d56c4e4
gh-101100: Add a table of class attributes to the "Custom classes" section of the data model docs (#124480) 2024-09-25 19:29:58 +00:00
Wei-Hsiang (Matt) Wang
cf472577e2
gh-123517: Remove unnecessary `:meth:` parentheses (#123518) 2024-09-01 05:59:42 +01:00
Serhiy Storchaka
1a0c7b9ba4
gh-121905: Consistently use "floating-point" instead of "floating point" (GH-121907) 2024-07-19 08:06:02 +00:00
Bénédikt Tran
f4d6e45c1e
gh-120452: improve documentation about private name mangling (#120451)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-07-13 07:45:18 -07:00
Danny Yang
91313afdb3
gh-114104: clarify asynchronous comprehension docs to match runtime behavior (#121175) 2024-07-01 22:04:39 +05:30
Paulo Freitas
bf5e1065f4
doc: Mention the missing reflected special methods for all binary operations (GH-119931) 2024-06-04 17:55:11 +00:00
Erlend E. Aasland
dbe44f150c
Docs: mark up NotImplemented using the :data: role throughout the docs (#116135) 2024-02-29 20:46:12 +00:00
Terry Jan Reedy
a1332a99cf
Clarify one-item tuple (#114745)
A 'single tuple' means 'one typle, of whatever length.
Remove the unneeded and slight distracting parenthetical 'singleton' comment.
2024-01-30 18:40:54 +00:00
Hugo van Kemenade
8ccd1ba461
gh-101100: Fix Sphinx warnings in reference/expressions.rst (#114194) 2024-01-22 18:21:14 +02:00
Sergey B Kirpichev
029ecee10d
gh-114070: fix token reference warnings in expressions.rst (#114169) 2024-01-17 18:39:50 +02:00
Raymond Hettinger
97f8f28b3e
gh-112331: Fix reference manual description of attribute lookup mechanics (gh-112375) 2023-11-25 16:20:53 -06:00
Terry Jan Reedy
9a2f25d374
gh-111944: Add assignment expression parentheses requirements (#111977)
gh-111944: Clarify where assignment expressions require ()s

Augment the list of places where parentheses are
required around assignnment statements.  In particular,
'a := 0' and 'a = b := 1' are syntax errors.
2023-11-12 19:06:50 -05:00
Adam Turner
da99133710
GH-101100: Fix reference warnings for `__getitem__` (#110118) 2023-10-19 18:05:05 +03:00
Ezio Melotti
41d8ec5a1b
gh-110631: Fix reST indentation in Doc/reference (#110708)
Fix wrong indentation in the Doc/reference dir.
2023-10-11 22:50:55 +02:00
Serhiy Storchaka
f2d07d3289
gh-101100: Sphinx warnings: pick the low hanging fruits (GH-107386) 2023-07-29 08:48:10 +03:00
Ned Batchelder
987b712b4a
Replace the esoteric term 'datum' when describing dict comprehensions (#106119) 2023-07-02 20:22:40 -07:00
Nicolas Tessore
d56c933992
gh-104770: Let generator.close() return value (#104771)
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2023-05-23 13:51:56 -07:00
Adam Turner
3e7995ca11
GH-97950: Use new-style index directive ('exception') (#104160) 2023-05-04 13:30:24 +03:00
Adam Turner
6ab463684b
GH-97950: Use new-style index directive ('object') (#104158)
* Uncomment object removal in pairindextypes

* Use new-style index directive ('object') - C API

* Use new-style index directive ('object') - Library

* Use new-style index directive ('object') - Reference

* Use new-style index directive ('object') - Tutorial
2023-05-04 13:04:41 +03:00
Adam Turner
b0ce2db118
GH-97950: Use new-style index directive ('operator') (#104156) 2023-05-04 12:03:11 +03:00
Adam Turner
33ca322c50
GH-97950: Use new-style index directive ('keyword') (#104153)
* Uncomment keyword removal in pairindextypes

* Use new-style index directive ('keyword') - Reference
2023-05-04 10:44:12 +02:00
Kumar Aditya
7feb6d2f85
fix grammer -> grammar typo in expressions.rst (GH-100683)
Automerge-Triggered-By: GH:AlexWaygood
2023-01-02 03:49:06 -08:00
ram vikram singh
1aab269d4a
gh-100201: Document behavior with a bare yield statement (#100416)
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
2023-01-01 21:06:13 +05:30
Gerardwx
d578aaea62
Python documents state elsewhere that a comma is not an operator, so … (GH-98736)
…calling it an operator here is confusing. See https://docs.python.org/3/reference/lexical_analysis.html#operators and https://docs.python.org/3/faq/programming.html#id22.
2022-10-26 23:33:42 -07:00
Hugo van Kemenade
296313002f
gh-97913 Docs: Add walrus operator to the index (#97921)
* Add walrus operator to the index

* Add named expression to the index

Co-authored-by: Mariatta Wijaya <Mariatta@users.noreply.github.com>

* Fix indentation and add missing newline

Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>

Co-authored-by: Mariatta Wijaya <Mariatta@users.noreply.github.com>
Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
2022-10-08 08:54:16 +02:00
Hugo van Kemenade
fa2d43e518
Docs: Fix backtick errors found by sphinx-lint (#97998)
Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
2022-10-06 18:01:30 -07:00
Terry Jan Reedy
2b5f1360ea
gh-86482: Document assignment expression need for ()s (#23291)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-10-06 12:24:17 -07:00
Ofey Chan
83a3de4e06
gh-96348: Deprecate the 3-arg signature of coroutine.throw and generator.throw (GH-96428) 2022-09-30 09:43:02 +01:00
Andrew Kay
d582edf0be
Fix docs on conditional expression grouping (GH-96447) 2022-09-27 21:57:32 -05:00
Jeff Allen
9d432b4a18
gh-96397: Document that keywords in calls need not be identifiers (#96393)
This represents the official SC stance, see
https://github.com/python/steering-council/issues/142#issuecomment-1252172695
2022-09-22 11:10:15 -07:00
luzpaz
830513754d
gh-93675: Fix typos in Doc/ (GH-93676)
Closes #93675
2022-06-21 21:10:45 +02:00
Zackery Spytz
fb082c2fc5
bpo-45393: help() on operator precedence has misleading entries (GH-31246)
Fix the formatting for "await x" and "not x" in the operator
precedence table.
2022-05-19 17:05:04 +02:00
Dave Goncalves
8be7c2bc5a
bpo-14911: Corrected generator.throw() documentation (GH-32207)
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
2022-03-31 16:56:48 +03:00
Alex Waygood
50731297a9
bpo-45680: Improve docs on subscriptions w.r.t. GenericAlias objects (GH-29479) 2022-03-07 19:49:28 -08:00
Jacob Walls
273cb8e757
bpo-24650: Use full term "generator function" in yield expressions docs (GH-24663) 2022-01-07 18:39:40 +00:00
Arthur Milchior
32959108f9
bpo-45640: [docs] Tokens are now clickable (GH-29260)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2021-11-18 17:06:38 +01:00
Ethan Furman
6ecead106a
[doc] minor fixes to expressions.rst (GH-29444) 2021-11-06 10:26:43 -07:00
Tim Peters
51ed2c56a1
bpo-45530: speed listobject.c's unsafe_tuple_compare() (GH-29076)
Keep track of whether unsafe_tuple_compare() calls are resolved by the very
first tuple elements, and adjust strategy accordingly. This can significantly
cut the number of calls made to the full-blown PyObject_RichCompareBool(),
and especially when duplicates are rare.

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2021-10-24 22:27:24 -05:00