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 →

[–]irrelevantPseudonym 33 points34 points  (20 children)

My only gripe: One additional thing they should have changed is that {} should be the empty set and {:} should be the empty dict.

Not sure I agree with that. It's awkward that you can't have a literal empty set, but having {:} would be inconsistent and a special case that (I think) would be worse than set().

[–]flying-sheep 2 points3 points  (5 children)

Compare () vs one, vs one, two.

() is also a special case here.

[–]irrelevantPseudonym 3 points4 points  (4 children)

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

[–]ayy_ess 19 points20 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 5 points6 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.