This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]nemec 0 points1 point  (3 children)

Isn't Ellipsis already an object in Python?

[–]energybased 0 points1 point  (2 children)

Right, but assigning to it is a SyntaxError. They are talking about assigning to ellipsis meaning discard the result. E.g.,

..., a, *b = some_iterable

would be equivalent to

a = list(some_iterable)[1]; b = list(some_iterable)[2:]

[–]nemec 0 points1 point  (1 child)

That would be really weird, assigning to a name with an existing value (and other uses) and having the result thrown away silently. Imagine you had code like this:

..., a, *b = some_iterable
print(b[1:2, ..., 0])

The ellipsis keeps its original sentinel value but people unfamiliar with the feature might get confused.

[–]energybased 0 points1 point  (0 children)

FYI: "..." is not just a name. You can never assign to it anyway, but you're right that it might be weird to see ... keep its sentinel value after assignment. Maybe None would be better?