On 08Nov2021 23:32, MRAB <pyt...@mrabarnett.plus.com> wrote: >On 2021-11-08 22:10, Cameron Simpson wrote: >>>{} in {1:'a', 'b':2] <-- TypeError because of hashability >>>set() in {1, 2, 'a', 'b'} <-- ditto >>>[] in ['a', 'b', 1, 2] <-- False >> >>Right. Also, the members are not dicts or sets, respectively. >> >More precisely, none of the keys are an empty set.
Aye, for the examples. But I was highlighting that the set/lists members are a different type from the left-hand thing (empty set/list). A category error, to my mind. >>>SomeFlag.nothing in SomeFlag.something <-- ??? >> >>I would expect "true", myself. >> >I'm not so sure. > >A flag could be a member, but could a set of flags? Probably one flavour should raise a TypeError then with this comparison. I wouldn't want "member flag present in SomeFlag.something" and "set-of-members present in SomeFlag.something" to both be valid, there is so much scope for ambiguity/accidents there. I would rather punt the "set-of-members present" off to "<"/"<=" if we want to say either (which of course we should be able to say). So: To me "SomeFlag.nothing" is a set of flags, empty. _Not_ an individual flag (a member). Which means that _if_ we had a subset/strict-subset test, I'd want "SomeFlag.nothing in" to raise a TypeError, since we should use the subset/strict-subset operator for that flavour. Which means I'm backtracking to TypeError, not 'true". _Provided" this is a "member in set" comparison. Of course, I think resently we don't distinguish a flag combination name (".nothing", ".red_and_blue"==0b11) from single flags overtly. If there are trite, _fast_, way to test count_of_flags(flag_value)==1 ? i.e. can "members" be automatically distinguished from flag combinations (obviously such a definition would exclude a combination-of-just-1-flag). >>I was going to digress about "<" vs "in". For sets, "<" means subset >>and >>"in" means "element in set". That isn't exactly parallel to flags. What >>if "SomeFlag.nothing < SomeFlag.something" meant a subset test? Would we >>need "in" at all? Or is "<" out of the picture because FLags, or at >>least IntFlags, might do numeric-like stuff with "<"? >> >Actually, '<' means _proper_ subset (not ==), '<=' means subset >(possibly ==). Point taken. I'll try to be more precise. Warning: I'll become more wordy. Cheers, Cameron Simpson <c...@cskk.id.au> _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/5SQCDE7HMKQUTAQPZKAK2SWZZ22SN36D/ Code of Conduct: http://python.org/psf/codeofconduct/