> It’s ugly, but it makes it perfectly clear that the operation is creating a new dictionary.
I don't see how " * * " makes it clear that a new dictionary is created. Generally speacking, I tend to find operators for complex data structures unclear and don't understand their appeal. It is pretty much the same thing as having methods using two letters long names which everybody would find unacceptable.
Can you spontaneously guess the difference between "d1 + d2", "d2 + d1" and "d1 += d2" with d1 and d2 being hashtables ? Personally I can't. I'm strongly of the opinion that defining a sum for types where a sum is not obvious is a bad idea especially when said sum is non commutative.
From my point view, this is the kind of abuse that make Haskell so annoying to read (with abuse of point free style). I would be sad to see Python go this way.
It’s already the case for lists, and no-one is confused. (I have taught intro courses to python). People do however get confused as to why it doesn’t work for dictionaries, because it’s intuitive to expect it would when it works for lists. And none one seems to be confused about the non communicative nature (most don’t know what that means anyway) they find it natural that adding lists puts the first list first.
3 comments
[ 2.1 ms ] story [ 22.5 ms ] threadI don't see how " * * " makes it clear that a new dictionary is created. Generally speacking, I tend to find operators for complex data structures unclear and don't understand their appeal. It is pretty much the same thing as having methods using two letters long names which everybody would find unacceptable.
Can you spontaneously guess the difference between "d1 + d2", "d2 + d1" and "d1 += d2" with d1 and d2 being hashtables ? Personally I can't. I'm strongly of the opinion that defining a sum for types where a sum is not obvious is a bad idea especially when said sum is non commutative.
From my point view, this is the kind of abuse that make Haskell so annoying to read (with abuse of point free style). I would be sad to see Python go this way.