set.add() doesn't replace equal element

Paul Bryan pbryan at anode.ca
Fri Dec 30 16:47:59 EST 2022


What kind of elements are being added to the set? Can you show 
reproducible sample code?

On Fri, Dec 30 2022 at 03:41:19 PM -0600, Ian Pilcher 
<arequipeno at gmail.com> wrote:
> I just discovered this behavior, which is problematic for my 
> particular
> use.  Is there a different set API (or operator) that can be used to
> add an element to a set, and replace any equal element?
> 
> If not, am I correct that I should call set.discard() before calling
> set.add() to achieve the behavior that I want?
> 
> --
> ========================================================================
> Google                                      Where SkyNet meets 
> Idiocracy
> ========================================================================
> --
> <https://mail.python.org/mailman/listinfo/python-list>



More information about the Python-list mailing list