Commit Graph

81 Commits

Author SHA1 Message Date
Nick Coghlan cd292d8997
PEP 572: TargetScopeError->SyntaxError, other SyntaxError adjustments (#1140)
- switch from the new `TargetScopeError` to a plain `SyntaxError`
  as per referenced python-dev discussion
- clarify rationale for those extra SyntaxError cases (we don't
  want current CPython implementation details to implicitly leak into
  the "do what CPython does" de facto language specification)
- broaden one of the error cases to handle the fact that CPython's
  symbol table analysis for a comprehension involves two different
  scopes and hence makes it difficult to detect when the target of
  a named expression in the iterable expression gets re-used as an
  iteration variable in the comprehension
- note that even dead code affects the symbol analysis pass
2019-08-14 12:30:53 +10:00
Logan Jones 6a705de78e Update PEP-572 for f-strings (see bpo-36798) (#1024)
See bpo-36798.

This update specifies the interplay between f-strings and
the assignment operator. Specifically, it attempts to
clarify how to use assignment operators inside of f-strings.
2019-05-06 11:30:23 -05:00
Pradyun Gedam 1282371c04 PEP 572: Mention the two minor changes in the Abstract (#739) 2018-07-13 07:40:27 -07:00
Guido van Rossum 8846efd623
PEP 572: Acceptance (#735)
- Delete 'Pending Acceptance' section
- Change reference implementation to proof of concept
- Add the ^L back before the Emacs Local Variables section
- Add Resolution link
2018-07-11 17:54:47 -07:00
Harmon c39a17cf11 PEP 572: Fix extra "than" typo (#734) 2018-07-10 17:43:29 -07:00
Chris Angelico f906b988b2 PEP 572: Add bullet point for lambda (#729)
Closes #728
2018-07-10 16:38:31 -07:00
Giampaolo Rodola 00c19f4a82
PEP 572: pass mandatory bufsize sock.recv() argument (#733)
* pass mandatory bufsize sock.recv() argument

* remove unnecessary space
2018-07-11 01:07:06 +02:00
Tim Peters 0919149969
PEP 572: clarify Appendix C example (#732)
* PEP 572:  clarify Appendix C example

Make very clear in the example that the function local remains unbound until the caller executes the genexp.
2018-07-10 17:17:34 -05:00
Dmitry Alimov 801bfd1b0f Remove extra curly brace from dict display example (#730) 2018-07-10 14:05:30 -07:00
Guido van Rossum e57063cb6e
PEP 572: Assorted fixes suggested by Rob Cliffe (#719)
Also replace the file-based example with a better one by Giampaolo Rodola'.
2018-07-10 11:19:10 -07:00
Nick Coghlan 05cd2883f7 PEP 572: Annotations are supported, via separate declarations (#724) 2018-07-10 11:08:09 -07:00
Guido van Rossum 9c61127920
PEP 572: Tweaks suggested by Glenn Linderman and Tim Peters (#718)
* PEP 572: Tweaks suggested on python-dev by Glenn Linderman.
* Use Tim's rewording of the exceptional cases.
* Clarify that TargetScopeError is a *new* subclass of SyntaxError.
2018-07-10 11:02:30 -07:00
Brett Cannon 145c034e89
Disambiguate 'if' as syntax and not grammar 2018-07-10 09:53:48 -07:00
JimJJewett 8606d403fb occurrs -> occurs typo (#725) 2018-07-10 09:29:03 -07:00
Georg Brandl d6fcb1c735 PEP 572: disallow ungrouped assign-expr in annotations (#720) 2018-07-10 08:05:11 -07:00
Guido van Rossum 44ee870453 PEP 572: Delete objection about ugly code (#717)
See https://twitter.com/asmeurer/status/1016522016160022528
2018-07-10 23:23:29 +10:00
Mariatta 8a3ed368bb
PEP 572: use double backticks for the ``with`` keyword. (#716) 2018-07-09 20:31:21 -07:00
Jonathan Goble 6781796a53 PEP 572: Fix typo ("assing -> assign") (#715) 2018-07-09 19:32:24 -07:00
Guido van Rossum 26e6f61fab PEP 572: Add new Post-History date 2018-07-09 15:20:10 -07:00
Chris Angelico 096ef3b37f
PEP 572: Add an appendix to clarify that there's no magical scoping (#714) 2018-07-10 05:24:47 +10:00
Guido van Rossum 79480d5cde PEP 572: Fix a small issue found by Steve Dower, and clarify priority around commas. 2018-07-09 11:12:19 -07:00
Guido van Rossum 6a681307a6
PEP 572: Explain why 'as TARGET' is inferior (#711)
Also (perhaps superfluously) explain what's wrong with `->`.
2018-07-09 08:16:01 -07:00
Guido van Rossum 6cb044c0cc
PEP 572: Move the proposed evaluation order change to "Syntax and semantics" (#710)
Remove "Open questions and TODOs" since they're now all decided.
2018-07-08 21:36:28 -07:00
Guido van Rossum a9b8753635
PEP 572: Address several small issues (#709)
- Dropped "TODO: Include Guido's evidence, and do a more systematic search."
  I think the current text is good enough.

- Relented on assignment expressions in default values other than top
  level.  (Mainly because the syntactic/semantic check would be
  awkward, and it was already called out as a possible style
  recommendation instead.)

- Clarified that a lambda counts as "the current scope" (containing an
  assignment expression).

- Added prohibition on [... for i in i := ...].

- Specified that scope-related prohibitions should raise
  TargetScopeError, a subclass of SyntaxError.
2018-07-08 21:35:44 -07:00
Guido van Rossum bd6332d245
PEP 572: get rid of side-by-side tables; drop unnecessary TODO (#708)
Alas, the side-by-side tables caused horribly misindented code.
2018-07-08 15:27:52 -07:00
Guido van Rossum 97ff8893b0
PEP 572: Add Appendix B with translations of various comprehension cases (#700) 2018-07-08 08:28:47 -07:00
Neil Schemenauer 5bfcc17b8e Fix trivial typo in PEP 572 (#691) 2018-07-07 15:37:55 -07:00
Guido van Rossum 23a91023fa
Add PEP 572 examples from stdlib (#698) 2018-07-07 14:05:56 -07:00
Guido van Rossum 5232173ad6 Add pending acceptance note and some TODOs 2018-07-05 17:21:28 -07:00
Guido van Rossum 6d81538ecb
Pep 572 update (#654)
- Remove changes to comprehension scope
- Make := in comprehensions assign to containing non-comprehension scope
- Clarify binding precedence (tighter than comma, not at same level as =)
- Remove mention of more complex targets in the future
- Explicitly disallow toplevel :=
- Rewrite section on differences with =, enumerating all of them
- Remove "here's how this could be written without :=" from examples

- Tweak first paragraph of "Syntax and semantics"
- Add "Exception cases" (various explicit prohibitions)
- Clarify that lambda is a containing scope
- Clarify that := and = just don't mix
- Added "Open questions" section
- Added two new rejected alternatives: "Allowing commas to the right"
  and "Always requiring parentheses"
- Minor edits

* Start a section on real code

* Correct/clarify "commas to the right" section

* Add Tim and Guido as authors

* Update abstract to mention :=

* Rule out targets conflicting with comprehension loop control

* Add timcode.txt as Appendix A

* Add os.fork() example

* Add TODOs about evaluation order
2018-05-22 12:49:00 -07:00
Chris Angelico 433faca4cf PEP 572: Reword slightly to remove reference to students 2018-04-26 22:39:09 +10:00
Chris Angelico 4d93701cce PEP 572: Add additional motivation and examples 2018-04-25 15:32:22 +10:00
Chris Angelico 5466fb4518 PEP 572: Post anew 2018-04-25 01:29:49 +10:00
Chris Angelico b2378e6a59 PEP 572: Clarify wording 2018-04-24 17:22:41 +10:00
Chris Angelico 327d54250c PEP 572: Weaken proposal / strengthen requirements from "target" to "name" 2018-04-24 16:58:40 +10:00
Chris Angelico 1a3e52e197 PEP 572: Massively simplify and remove verbiage 2018-04-20 12:53:15 +10:00
Chris Angelico d3a5143cbc PEP 572: Acknowledge Guido and Christoph for the PEP's pivot 2018-04-18 23:15:42 +10:00
Chris Angelico b5a9edf7b4 PEP 572: Use the sloppy term "variables" instead of the strict-but-inaccurate "names" (since any assignment target is valid) 2018-04-18 23:05:10 +10:00
Chris Angelico 73715149df PEP 572: Final updates prior to posting to python-dev 2018-04-17 17:40:51 +10:00
Chris Angelico 1129ab3aa3 PEP 572: Mention another alternate syntax 2018-04-16 06:42:37 +10:00
Chris Angelico cf7e061167 PEP 572: Mention another rejected syntax 2018-04-13 22:40:36 +10:00
Chris Angelico ed718f5186 PEP 572: Clarify the problems with 'as' 2018-04-13 21:59:40 +10:00
Chris Angelico 5c2778d403 PEP 572: Update based on implementation experimentation 2018-04-13 21:34:33 +10:00
Chris Angelico 31841b36cb PEP 572: Fix markup 2018-04-13 09:29:27 +10:00
Chris Angelico 3560ce6d8c PEP 572: Fix what appears to be broken markup, though I don't quite see why 2018-04-12 23:42:53 +10:00
Chris Angelico cc611e43b8 PEP 572: Update based on feedback from python-ideas 2018-04-12 23:39:05 +10:00
Chris Angelico 582dfee5d0 PEP 572: Fix example to more accurately reflect reality 2018-04-11 19:47:12 +10:00
Chris Angelico 356c97ef43 PEP 572: Fix wording (thanks Ethan) 2018-04-11 16:21:15 +10:00
Chris Angelico 1a7c830cdb PEP 572: Add one open question 2018-04-11 15:30:34 +10:00
Chris Angelico c51be3df34 PEP 572: Fix markup (wow, I pushed the same bug twice in one day...) 2018-04-11 15:23:04 +10:00