Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

There's got to be more to life than compile-and-go.


devel / comp.lang.python / Re: frozenset can be altered by |=

SubjectAuthor
o Re: frozenset can be altered by |=Chris Angelico

1
Re: frozenset can be altered by |=

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: rosuav@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: frozenset can be altered by |=
Date: Tue, 30 Nov 2021 12:44:51 +1100
Lines: 53
Message-ID: <mailman.65.1638236703.9869.python-list@python.org>
References: <CABbU2U_79XPx1T6EGWEniYkN8_m0oOO6mxx+HNbaLqg_wmT-Gw@mail.gmail.com>
<CAPTjJmq=4+yEhibTJoNA3QVUNR1HmScgnQgx3NtQRpgG4aNY1Q@mail.gmail.com>
<AM0PR07MB57000CEF0CEABBD27EA941DA879F9@AM0PR07MB5700.eurprd07.prod.outlook.com>
<CAPTjJmpprmCdjOJBz5FVecV6KqKFRC6Y7bOsNoTP+W-t-k3vew@mail.gmail.com>
<CABbU2U-rDQr0xkySeMsArbnox32TMdPO28SnbWtjbRhU7xzERA@mail.gmail.com>
<CABbU2U_+t+Gg0EXaz3hc6V5xBG=TooCzMazWLLboM8fgSc1u5w@mail.gmail.com>
<CAPTjJmr2cQEuD=q1rLfx8-LwgTrfuJz5FTXYaPB9HB-a1Ef4wQ@mail.gmail.com>
<2bfd366f-9ba0-a024-204c-01c33e4112d6@Damon-Family.org>
<CAPTjJmoLaQTXvpXfG6=MVLE0B+3BuKuCg_FkU-feoXyGxKHNJA@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de UDAH86fnq3EubxJPs+4InQSRgCbWo11tKZ93WDhnz3hA==
Return-Path: <rosuav@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=ApshbMcb;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.023
X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'explicitly': 0.07;
'python.': 0.08; 'angelico': 0.09; 'confusing,': 0.09; 'damon':
0.09; 'docs,': 0.09; 'operators': 0.09; 'set,': 0.09;
'url:reference': 0.09; '>>>>': 0.16; 'applies': 0.16; 'behaviour':
0.16; 'chrisa': 0.16; 'confusing.': 0.16; 'default.': 0.16;
'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16;
'level,': 0.16; 'wrote:': 0.16; 'python': 0.16; 'probably': 0.17;
'uses': 0.19; 'pm,': 0.19; 'tue,': 0.19; 'to:addr:python-list':
0.20; 'language': 0.21; 'anything': 0.25; 'section': 0.25;
'behavior': 0.26; 'binary': 0.26; 'object': 0.26; 'else': 0.27;
'bit': 0.27; '>>>': 0.28; 'chris': 0.28; 'code,': 0.31; "doesn't":
0.32; 'question': 0.32; 'here,': 0.32; 'message-
id:@mail.gmail.com': 0.32; 'but': 0.32; "i'm": 0.33; 'particular':
0.33; 'same': 0.34; 'work.': 0.34; 'header:In-Reply-To:1': 0.34;
'received:google.com': 0.34; 'from:addr:gmail.com': 0.35;
'functions': 0.36; 'mon,': 0.36; 'using': 0.37; "it's": 0.37;
'received:209.85': 0.37; 'way': 0.38; 'put': 0.38; 'received:209':
0.39; 'adding': 0.39; 'single': 0.39; 'something': 0.40; 'should':
0.40; 'view': 0.60; 'seen': 0.62; "you'd": 0.64; 'down': 0.64;
'explained': 0.64; 'richard': 0.64; 'listed': 0.67; 'now,': 0.67;
'back': 0.67; 'only.': 0.69; 'type:': 0.69; 'times': 0.69;
'above,': 0.70; 'too.': 0.70; '2021': 0.71; 'little': 0.73;
'left': 0.83; 'converted': 0.84; 'strings': 0.84; 'sulla': 0.84;
'true:': 0.84; 'fall': 0.95
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to;
bh=rxChTH60MH0zmI4CYBSqmJrqe+umHAZ8oL3ni6KQhIM=;
b=ApshbMcbaA9EYGreiQ/3bAy5WUZSGc3JnYRMEAcANqcL1N41oBOnsb4hHxeH52q0j0
rLAhnw6hU13FpBvUdiIXdTtN8kCp4PQ+0CgF00rvOsH4g4LuCZSSeE+mqmRjlU4UPIDA
jvJ8lNXy7gQvDR0K3mSiSMrfn43SCZAss3qONxH8hyvASyXzkQxftFB1N9l4kmcBe7IR
4UjXUV11NjZ2NEoUjwu5EEQmRGzawX/X3p24p7XBnNt8jGAl4RUqGTBd2vW0srMXIgmm
prq08LCA0bpNwYIHgZ93yTPJGVXd0cEO/Nb82iMuStPAthtidXWcfwGyYq5SF8nGsk5q
y92A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to;
bh=rxChTH60MH0zmI4CYBSqmJrqe+umHAZ8oL3ni6KQhIM=;
b=dDthJCKacJzqU34eYZlXjTimwRa+qdxiX2zQnPBXKi4XCZRZtNg/XBdnWxhcYJXQ5d
VwksV/lZxTb5w5z7KVUp6Fgmzur/vEFBBEtbIlKeXGunVOdwHEKEBwwIrB/BWI//t+cV
5xNKN1AKzfkzH3255qj4NScyQrG+bM7oinCpzyYz0vyALeVS433cavHlmKxUMSAIwRLn
4kePRiWz2ViDRQP/UNqg/kS+fStio38/ueQI7gLDDkd5f7yQUsF5slVlpEEsZsPchvOL
35cKqgh+sWamM50CVGT8JhbsxzJXuRm+l3mL7QPILenbH5k6tT+6PQ6x9REkfE+mcQ8B
JGPQ==
X-Gm-Message-State: AOAM530OxOllFwVeLlt1pcR1lJL1Z6i9ZeE88WUQ0YHxSs+P0QLK5v73
l34+Xv6abN4V3CG0o/TmgS1QdOk4OMManvryTxaj94KsBpA=
X-Google-Smtp-Source: ABdhPJyoSvk7nAKBj5StdqmZPSJRh+NBHSHwbZkBe64lYgRlgna+wVe4p4GJwmj4CXULHNQggt068TF8Fijrgbfj9os=
X-Received: by 2002:a1c:540c:: with SMTP id i12mr1703600wmb.33.1638236702269;
Mon, 29 Nov 2021 17:45:02 -0800 (PST)
In-Reply-To: <2bfd366f-9ba0-a024-204c-01c33e4112d6@Damon-Family.org>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.37
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: <CAPTjJmoLaQTXvpXfG6=MVLE0B+3BuKuCg_FkU-feoXyGxKHNJA@mail.gmail.com>
X-Mailman-Original-References: <CABbU2U_79XPx1T6EGWEniYkN8_m0oOO6mxx+HNbaLqg_wmT-Gw@mail.gmail.com>
<CAPTjJmq=4+yEhibTJoNA3QVUNR1HmScgnQgx3NtQRpgG4aNY1Q@mail.gmail.com>
<AM0PR07MB57000CEF0CEABBD27EA941DA879F9@AM0PR07MB5700.eurprd07.prod.outlook.com>
<CAPTjJmpprmCdjOJBz5FVecV6KqKFRC6Y7bOsNoTP+W-t-k3vew@mail.gmail.com>
<CABbU2U-rDQr0xkySeMsArbnox32TMdPO28SnbWtjbRhU7xzERA@mail.gmail.com>
<CABbU2U_+t+Gg0EXaz3hc6V5xBG=TooCzMazWLLboM8fgSc1u5w@mail.gmail.com>
<CAPTjJmr2cQEuD=q1rLfx8-LwgTrfuJz5FTXYaPB9HB-a1Ef4wQ@mail.gmail.com>
<2bfd366f-9ba0-a024-204c-01c33e4112d6@Damon-Family.org>
 by: Chris Angelico - Tue, 30 Nov 2021 01:44 UTC

On Tue, Nov 30, 2021 at 12:41 PM Richard Damon <Richard@damon-family.org> wrote:
>
> On 11/29/21 5:01 PM, Chris Angelico wrote:
> > On Tue, Nov 30, 2021 at 8:55 AM Marco Sulla
> > <Marco.Sulla.Python@gmail.com> wrote:
> >> I must say that I'm reading the documentation now, and it's a bit
> >> confusing. In the docs, inplace operators as |= should not work. They
> >> are listed under the set-only functions and operators. But, as we saw,
> >> this is not completely true: they work but they don't mutate the
> >> original object. The same for += and *= that are listed under `list`
> >> only.
> >>
> > Previously explained here:
> >
> >>> On Mon, 22 Nov 2021 at 14:59, Chris Angelico <rosuav@gmail.com> wrote:
> >>>> Yeah, it's a little confusing, but at the language level, something
> >>>> that doesn't support |= will implicitly support it using the expanded
> >>>> version:
> >>>>
> >>>> a |= b
> >>>> a = a | b
> >>>>
> >>>> and in the section above, you can see that frozensets DO support the
> >>>> Or operator.
> >>>>
> >>>> By not having specific behaviour on the |= operator, frozensets
> >>>> implicitly fall back on this default.
> >>>>
> > The docs explicitly show that inplace operators are defined for the
> > mutable set, and not defined for the immutable frozenset. Therefore,
> > using an inplace operator on a frozenset uses the standard language
> > behavior of using the binary operator, then reassigning back to the
> > left operand.
> >
> > This is a language feature and applies to everything. You've seen it
> > plenty of times with integers, and probably strings too. A frozenset
> > behaves the same way that anything else does.
> >
> > ChrisA
>
> I suppose the question comes down to is it worth adding a reminder in
> the description of the inplace operators that if a type doesn't support
> the inplace operator, it is automatically converted into the equivalent
> assignment with the binary operator?
>

My view is: no, because you'd have to put that reminder on every
single object in Python. The details are here, and apply to all Python
code, not to any particular type:

https://docs.python.org/3/reference/simple_stmts.html#augmented-assignment-statements

ChrisA


devel / comp.lang.python / Re: frozenset can be altered by |=

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor