On Mon, Jun 29, 2020, at 04:51, Stephen J. Turnbull wrote:
> Of course, we may prefer a boolean return, despite the general rule
> about returning elements.  I'm single-threaded, and so agnostic on
> that. :-)  But if it turns out that somebody *wants* to check "2 is 
> 2.0",
> this .add_unique can serve both purposes.

I don't think this is a good idea - for one thing, an element return means you 
can't handle, or have to handle specially, None being in a set.

If we want a way to check the type or identity of an item in a set, I think it 
would be best to add another method to access the item. Or an operator - i.e. 
check if type(set[2]) is int or float, or whatever it is you want. I did once 
write a way to do that in O(1) time in unmodified python [abusing the __eq__ 
method of a custom class to  smuggle the value out] as an exercise, 
incidentally, and it seemed to work fine.
_______________________________________________
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/NBMII2CZRA7SSZSRMH3LTDUECUQV3BGB/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to