4 ms·
That ain't orthogonality, this is orthogonality: dict() = {} set() = <> tuple() = () list() = [] (btw, does anyone actually use `<>` as `!=`?)
by polemic 14y ago
That ain't orthogonality, this is orthogonality:
dict() = {}
set() = <>
tuple() = ()
list() = []
(btw, does anyone actually use `<>` as `!=`?)
- Erwin 14y agoThey finally got rid of <> in Python 3 (together with the `` as being alias for repr).
- masklinn 14y agoAnd they're not going to add new syntax to Python 2.7 (and the core team has been empathetic that there would not be a 2.8), so `<>` could easily be repurposed for "empty set". Of course `<1, 2, 3, 4>` would then have to be an alternative set literal.
- shabble 14y ago<pedant type="confused">emphatic?</pedant>
- andreasvc 14y agoThis would conflict with greater/smaller than operators, which are also used on sets to express sub/superset relations. If it wouldn't cause trouble in the formal grammar, then at least in terms of readability.
- masklinn 14y ago> This would conflict with greater/smaller than operators, which are also used on sets to express sub/superset relations. Not any more than `[` being used for both literal lists and indexing. > If it wouldn't cause trouble in the formal grammar, then at least in terms of readability. It wouldn't cause the slightest trouble in the grammar, and I don't think it'd cause much if any trouble for readability either.
- andreasvc 14y agoIn terms of readability the angular brackets arguably don't nest well: <<<0, 1>, 2>, 3>. Also, having braces for sets happens to coincide with mathematical notation. Angular brackets would be more appropriate for tuples, in this regard--although the brackets used for tuples in mathematical notation are less acute: \langle and \rangle in LaTeX. I think it's pretty unfortunate that for practical purposes we're forced to make do with what's available in the ASCII character set, which is pretty much an accident of history. My favorite solution to the OP's problem would be to use the Unicode empty set symbol. People who for some reason aren't able to type it could fall back to set(), and in terms of reading it will be immediately obvious to everyone that the empty set is intended, which doesn't hold for all the ad-hoc solutions suggested until now.
- derefr 14y agoIt seems to me that our real problem here is the dearth of easily-accessible bracket characters on US-standard keyboards: x = 【1, 2, 3】 y = 【】 ;)