Issue 4339: Fix set-like dictview doc (original) (raw)

I see two problems with the current (.rc2) doc on "Dictionary view objects" that are set-like.

  1. The first paragraph of the section ends with the fragment

"The keys and items views have a set-like character since their entries"

This is not only incomplete, but wrong. Items views are set-like (entries are unique and hashable) only if all values are hashable, as revealed way at the end in a 'warning' that is only needed because of the previous over-generalization. I recommend that this fragment, the one sentence after the 'x in dictview' entry, and the warning be combined into one paragraph that tells the complete story at the appropriate place, which is where the 'one sentence' is now.

"Keys views are set-like since their entries are unique and hashable. If all values are hashable, so that (key,value) pairs are unique and hashable, then an items view is also set-like. (Values views are not treated as set-like since the entries are generally not unique.) Let 'set-view' and 'other' each be a set or set-like view. Then the following set operations are available."

This suggestion also addresses the second problem I see. The set operations are symmetric, but 'dictview op other' is not. It excludes the valid combination 'set op dictview'. So I think all 4 ops should be listed as 'set-view op other' instead, after the revised introduction above.