Skip to content

Commit 831e725

Browse files
PEP 637: Allow empty starred arguments (GH-1744)
Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
1 parent fc43230 commit 831e725

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

pep-0637.rst

+12-4
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ example use case 1, where a slice is accepted.
290290

291291
The successful implementation of this PEP will result in the following behavior:
292292

293-
1. An empty subscript is still illegal, regardless of context::
293+
1. An empty subscript is still illegal, regardless of context (see Rejected Ideas)::
294294

295295
obj[] # SyntaxError
296296

@@ -394,7 +394,7 @@ The successful implementation of this PEP will result in the following behavior:
394394
The following notation equivalence should be honored::
395395

396396
obj[*()]
397-
# Error. Equivalent to obj[]
397+
# Equivalent to obj[()]
398398
399399
obj[*(), foo=3]
400400
# Equivalent to obj[foo=3]
@@ -414,7 +414,7 @@ The successful implementation of this PEP will result in the following behavior:
414414
The following notation equivalent should be honored::
415415

416416
obj[**{}]
417-
# Error. Equivalent to obj[]
417+
# Equivalent to obj[()]
418418
419419
obj[3, **{}]
420420
# Equivalent to obj[3]
@@ -836,7 +836,15 @@ This proposal already established that, in case no positional index is given, th
836836
passed value must be the empty tuple. Allowing for the empty index notation would
837837
make the dictionary type accept it automatically, to insert or refer to the value with
838838
the empty tuple as key. Moreover, a typing notation such as ``Tuple[]`` can easily
839-
be written as ``Tuple`` without the indexing notation.
839+
be written as ``Tuple`` without the indexing notation.
840+
841+
However, subsequent discussion with Brandt Bucher during implementation has revealed
842+
that the case ``obj[]`` would fit a natural evolution for variadic generics, giving
843+
more strength to the above comment. In the end, after a discussion between D'Aprano,
844+
Bucher and the author, we decided to leave the ``obj[]`` notation as a syntax
845+
error for now, and possibly extend the notation with an additional PEP to hold
846+
the equivalence ``obj[]`` as ``obj[()]``.
847+
840848

841849
Sentinel value for no given positional index
842850
--------------------------------------------

0 commit comments

Comments
 (0)