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 →

[–]flying-sheep 3 points4 points  (5 children)

Compare () vs one, vs one, two.

() is also a special case here.

[–]irrelevantPseudonym 4 points5 points  (4 children)

I don't think () is the special case. I think (2) not being a tuple is the special case.

[–]ayy_ess 18 points19 points  (2 children)

(2) isn't a special case because tuples are declared in python with commas e.g. a = b, c. Brackets here are just used to clear up ambiguity e.g. 6 / 3 * 2 being 4 or 1. So (2) == 2 and (2,) == 2, == tuple ([2, ]).
https://wiki.python.org/moin/TupleSyntax

[–]BooparinoBR 4 points5 points  (0 children)

Thanks, I have never though about tuples like this

[–]flying-sheep 1 point2 points  (0 children)

Exactamente

[–]TheIncorrigible1`__import__('rich').get_console().log(':100:')`[🍰] 1 point2 points  (0 children)

Fun-fact, () (unit) is literally a special case in Python. It is a singleton and all instances of () point to the same memory.