Hacker News new | ask | show | jobs
by zwegner 4603 days ago
I've thought that dict.items() should be the default behavior for a while, but haven't really thought it through. The 'key in dict' example is interesting--is the expected semantics of 'x in y' for sequence types the same as 'any(x == z for z in y)'? That doesn't hold true for strings, as an example.
1 comments

is the expected semantics of 'x in y' for sequence types the same as 'any(x == z for z in y)'?

For sequences that aren't strings, yes. :-) Strings are a sort of hybrid between "atomic" values and sequences, so their semantics can be different.