Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

  >>> { 'a' : 1 } | { 'a' : 2 }
ISTM the most logical result would be:

  { 'a' : { 1, 2 } }
...but I could certainly understand throwing an exception.


While I see your point, I don't think this makes sense historically. Dictionaries never supported such behavior before so you'd be introducing a new core concept to a dictionary. But moreover, you'd be changing the type of the value only on duplicated keys, and what about if you were to add another value of 2 to a? Are you making this a set, and why? I think it would come with too many caveats and assumptions in the PEP.

I'm not saying you have a bad idea/logic here, just that I'm not sure it's the best thing for the dict.


Note that this forgets the order of the arguments, which may not be desirable


If the property we want to achieve is "a | b == b | a" we necessarily have to forget the order of the arguments.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: