-1 strongly. This will hide crucial type errors.
One could argue that aDict.keys() could behave as a set though. > On 17 Sep 2019, at 17:03, Rupert Spann <rupert.sp...@ska.ac.za> wrote: > > > related to: pep-0584, PEP-0218, and ??? > > The request is that since dictionary keys can not be duplicated / are unique > that they may behave the same as sets - and have the set operators actions > and return sets. > eg.: > > aSet = set('a','b','c','bar') > aDict = {'a':'aaa', 'b':'baa' , 'foo':fou' } > bDict = {'a':'ea', 'b':'bee' , 'foo':fuh', 'bar': 'drink' } > > aSet | aDict | bDict > = set('a','b','c','foo','bar') > > bDict & aDict > =set('a','b','foo') > > bDict - aSet > =set('foo') > > aDict^bDict > =set('bar') > > The dictionary class would support set filtering: > New_dict_from_set = { your_key: old_dict[your_key] for your_key in aSET } > e.g. a function such as: (taking the intersection) > aDict.Subdictionary(aSet) > ={'a':'aaa', 'b':'baa'} > > set(dictionary) would return the Keys (as a mutable). > > Adding an element to the mutable set would add a None as a value to the > dictionary. > > > > The "-=", "-", "+", "+=" would behave as specified in pep-0584 if both are > dictionaries, but if one of the operands is a set - a set is returned. > > The behaviour of > bDict.Subdictionary(aDict) > = {'a':'ea', 'b':'bee' , 'foo':fuh') > i.e. treats aDict as a set > > aDict.Subdictionary(List)== aDict.Subdictionary(Set(List)) > > > _______________________________________________ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/YY3KZZGEX6VEFX5QZJ33P7NTTXGPZQ7N/ > Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/TYD342GRECL3PZ5LL6PEMOQTLOZXOIVQ/ Code of Conduct: http://python.org/psf/codeofconduct/