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

For sets I can understand what + and - means: you can add or subtract the sets (not add or remove an element directly). This should be like lists, e.g.

    [10,20] + [30]
But what + and - would mean in the case of dicts is obscure. Better to just use full method names imho.


All my students disagree with you. They all try addition, and all expect a resulting dict with keys from both dicts. The fact the keys from the one side are prioritized is something they will learn once, just like with dict.update().


That's something a student may learn. But there will be plenty of people reading Python code that don't know how "+" works on dicts; and it is difficult to find out what it does because you can't easily Google/grep for the function name. Doing experiments with dicts is not something you want to be doing while you are reading other people's code.




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

Search: