4 ms·
You could argue that since `{}` is also technically an empty set, `dict()` is more explicit.
by colpabar 3y ago
You could argue that since `{}` is also technically an empty set, `dict()` is more explicit.
- masklinn 3y agoExcept `{}` is never an empty set.
- colpabar 3y ago> x = set() > x set() Well now I know! However I still think the shared usage of curly braces for dicts and sets could be somewhat confusing. > x = {1, 2, 3} > x {1, 2, 3} (But maybe no one should listen to me because I don't know how to do code blocks on HN.)
- tczMUFlmoNk 3y agoIndent by four spaces. :-)
- pwdisswordfishc 3y agoThe empty set is `{*()}`.
- matusp 3y agothis is beautiful
- alanwreath 3y agonever seen {*()} but I guess it is equivalent to set() I've noticed this in python in another place f"{var}" is the same as str(var) there was some other place I can't recall also noticing that (at least my perception understands that) Python is trying to kill my code golf tendencies. That said, it's probably just my own superstition and of course it doesn't remove my premature optimization tendencies...