Allow zero arguments for subscript syntax

Copying the response from Jelle here:

That would be a change to the grammar, so definitely not a minor feature that we can accept without prior discussion. In fact, it would probably need a PEP.

Your link shows 30k uses of [()]. That’s a lot, but in Implicit tuple return type - #61 by Nineteendo you found more than 30 million uses of x[a, b]—indicating that the x[()] syntax is not especially common. I glanced through the first few results; some are uses of the empty tuple type tuple[()], others are in various array or tensor libraries. I can’t speak for the latter, but from a typing perspective I think tuple[()] is a clearer spelling for the empty tuple type than tuple[].

1 Like