Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Computers don't actually think. You just think they think. (We think.)


devel / comp.lang.python / Re: set.add() doesn't replace equal element

SubjectAuthor
* set.add() doesn't replace equal elementIan Pilcher
`- Re: set.add() doesn't replace equal elementStefan Ram

1
set.add() doesn't replace equal element

<mailman.1326.1672436483.20444.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=25322&group=comp.lang.python#25322

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: arequipeno@gmail.com (Ian Pilcher)
Newsgroups: comp.lang.python
Subject: set.add() doesn't replace equal element
Date: Fri, 30 Dec 2022 15:41:19 -0600
Lines: 11
Message-ID: <mailman.1326.1672436483.20444.python-list@python.org>
References: <b3e4102c-c503-2579-ccac-285ce01d0f74@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de IrGtasxkl0uW+uxCqeG6DwC/Py0pwfRJv9uUpwIo9hqA==
Return-Path: <arequipeno@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=ZuMntSYB;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.108
X-Spam-Level: *
X-Spam-Evidence: '*H*': 0.80; '*S*': 0.02; 'set,': 0.09; 'subject:()
': 0.16; 'subject:element': 0.16; 'api': 0.17; 'message-
id:@gmail.com': 0.18; 'to:addr:python-list': 0.20; 'behavior':
0.26; 'header:User-Agent:1': 0.30; 'received:209.85.160': 0.31;
'there': 0.33; 'particular': 0.33; 'received:google.com': 0.34;
'from:addr:gmail.com': 0.35; 'received:209.85': 0.37;
'received:209': 0.39; 'should': 0.40; 'discovered': 0.80; 'skip:=
70': 0.84; 'meets': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=content-transfer-encoding:subject:from:to:content-language
:user-agent:mime-version:date:message-id:from:to:cc:subject:date
:message-id:reply-to;
bh=awLASh8VSGDae8/z7JiolwV9upa8f/8DtwboDnffBnc=;
b=ZuMntSYBYcyKnc878H3oAKqXZR+O5lyq2gIaGww0CfdFu/+l1y49HV88Q5X733BH6N
Ls13jwEU/MgfJfhP2esiku1AYHkrUXspg1wfzKzfzQFvoMGAa7Y5gujr/cs9D8Ieyq5Z
QHUK4LfXxG5dWwN2viacIvlaIUshkYqinwmJOq61qvWDn71EefGOqpkOWEOVbTTJdPGX
2bZKf0qmZml4cZIVyowdpQmhO3radPDE36qAQK9EeIcdCO4+jhZ7MwU1KyTtvfH8FOZh
f2rcK3FAih+3ucJbIDgPUZ7yohPDG61+8sCOQMu1f9Tix9qBc/q6m1BoWyWl7ZGetmEc
9g4g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=content-transfer-encoding:subject:from:to:content-language
:user-agent:mime-version:date:message-id:x-gm-message-state:from:to
:cc:subject:date:message-id:reply-to;
bh=awLASh8VSGDae8/z7JiolwV9upa8f/8DtwboDnffBnc=;
b=WjLPGitplUSyu/uvqo+rEHTNMy2EtjEMvCJnGK+99Kw5BYFFqIDlHr2ItDKT1ByQ+f
2RdNwynIKmF4NhRK/Ljzjq8HkAM37g/vXf+Z9eQKzILSYy/tIW6eW1K7YShun9yfm+lb
RRPGuii/mMNczef5pLkYPrxYh0D9mtXZxeplmUeJWpm0vFngwc7hyT9/MAt7PAvF0Sk6
t2fTKDxtgXM0nlXQvC5ZK8Zlp6SnjjX2TxajW9htN967zPml6R3UBaNG99X7hXHw2YMh
Qnd63TyxG5iN+diHGVmnlMXrXitQSgYLkLxlHbA8Y9UH7v5xZbtql2nEZgR4yvSUnqen
J78g==
X-Gm-Message-State: AFqh2kpQV0rLL3XshHnBVyLuZFIVsg4HdJ8GJjmt2bwSYCn4oZepmLMT
FwsCFXYoWPiLzTQq/DZhFQOwqDa7MhM=
X-Google-Smtp-Source: AMrXdXt8VDgLYQ7jQBzOMZOnYRj4U5z2/AnQ3u+/Ay4V66rDClXc4CpudENeiD0pwHlk/NRyL0/v4Q==
X-Received: by 2002:a05:6870:3d8d:b0:14f:b85a:becc with SMTP id
lm13-20020a0568703d8d00b0014fb85abeccmr11849548oab.48.1672436480684;
Fri, 30 Dec 2022 13:41:20 -0800 (PST)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.6.0
Content-Language: en-US
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <b3e4102c-c503-2579-ccac-285ce01d0f74@gmail.com>
 by: Ian Pilcher - Fri, 30 Dec 2022 21:41 UTC

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
========================================================================

Re: set.add() doesn't replace equal element

<set-add-20221230224443@ram.dialup.fu-berlin.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=25324&group=comp.lang.python#25324

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!news-2.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: set.add() doesn't replace equal element
Date: 30 Dec 2022 21:54:37 GMT
Organization: Stefan Ram
Lines: 13
Expires: 1 Dec 2023 11:59:58 GMT
Message-ID: <set-add-20221230224443@ram.dialup.fu-berlin.de>
References: <mailman.1326.1672436483.20444.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de eagXjJ2Y6CVlnR3dwiJppASVFfeM31eM3GZYhrJq275+6V
X-Copyright: (C) Copyright 2022 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE, en-US, it, fr-FR
 by: Stefan Ram - Fri, 30 Dec 2022 21:54 UTC

Ian Pilcher <arequipeno@gmail.com> writes:
>If not, am I correct that I should call set.discard() before calling
>set.add() to achieve the behavior that I want?

From the POV of a set, there are no "equal elements", but two
equal objects are just the same thing; so it makes no sense
to replace one by the other. You seem to want not a set but
something else. If you can get that behavior by using "set.
discard", you can use it. But that dissonance might be an early
warning that more problems with set might be waiting down
your road.


devel / comp.lang.python / Re: set.add() doesn't replace equal element

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor