Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

The idea of male and female are universal constants. -- Kirk, "Metamorphosis", stardate 3219.8


devel / comp.lang.python / Fwd: Proposal: Syntax for attribute initialisation in __init__ methods

SubjectAuthor
o Fwd: Proposal: Syntax for attribute initialisation in __init__ methodsSam Ezeh

1
Fwd: Proposal: Syntax for attribute initialisation in __init__ methods

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: sam.z.ezeh@gmail.com (Sam Ezeh)
Newsgroups: comp.lang.python
Subject: Fwd: Proposal: Syntax for attribute initialisation in __init__ methods
Date: Sat, 16 Apr 2022 23:05:03 +0100
Lines: 66
Message-ID: <mailman.142.1650146717.20749.python-list@python.org>
References: <CAD+b3HgooPwsBw06+SOtc3S8d9-wFzjzS-CuQSoTeLGikcDvpQ@mail.gmail.com>
<e4dc2443-8ea4-b121-9ba2-0dc0ebc74723@DancesWithMice.info>
<CAD+b3HgmWTbnSX0DT5T7uudOBTOiSFDMhzrOe87RqTU64bc9JQ@mail.gmail.com>
<CAD+b3Hg3hTs8HZGMs7WLdATP+BMWpyjJeqw3u_fxgE1b=hk5JA@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de TdDKzp2Q1DfnIwIkRf784Q2JbL8qstTg9eonqrAwUd2g==
Return-Path: <sam.z.ezeh@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=PMTioO7I;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.015
X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'argument': 0.04; '2022':
0.05; 'indicate': 0.05; '=dn': 0.09; 'enough.': 0.09;
'url:mailman': 0.15; '[1]:': 0.16; 'arguments': 0.16;
'attributes': 0.16; 'downside': 0.16; 'relatively': 0.16;
'subject:Syntax': 0.16; 'work!': 0.16; 'wrote:': 0.16; 'python':
0.16; 'says': 0.17; "can't": 0.17; 'to:addr:python-list': 0.20;
'fri,': 0.22; 'maybe': 0.22; 'skip:_ 10': 0.22; 'code': 0.23;
'anything': 0.25; 'url-ip:188.166.95.178/32': 0.25; 'url-
ip:188.166.95/24': 0.25; 'discussion': 0.25; 'url:listinfo': 0.25;
'url-ip:188.166/16': 0.25; 'classes': 0.26; 'so.': 0.26;
'subject:Fwd': 0.26; 'else': 0.27; 'function': 0.27; 'example,':
0.28; 'url-ip:188/8': 0.31; 'think': 0.32; 'concern': 0.32;
'maintaining': 0.32; 'point,': 0.32; 'message-id:@mail.gmail.com':
0.32; 'but': 0.32; "i'm": 0.33; 'subject:for': 0.33; 'there':
0.33; 'particular': 0.33; 'proposal': 0.33; 'same': 0.34; 'header
:In-Reply-To:1': 0.34; 'received:google.com': 0.34; 'following':
0.35; 'from:addr:gmail.com': 0.35; 'source': 0.36; 'missing':
0.37; "skip:' 10": 0.37; 'using': 0.37; 'received:209.85': 0.37;
'way': 0.38; 'received:209': 0.39; 'mentioned': 0.39; 'use': 0.39;
'subject:Proposal': 0.39; 'still': 0.40; 'advantage': 0.40;
'difficult': 0.40; 'something': 0.40; 'should': 0.40; 'gave':
0.61; "there's": 0.61; 'simply': 0.63; 'produce': 0.65; 'accept':
0.67; 'subject:skip:i 10': 0.69; 'url:archives': 0.69; 'above,':
0.70; 'raised': 0.70; 'potentially': 0.76; 'extra': 0.84;
'demand.': 0.84; 'reduces': 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=W39KuADT3iwB6lsSd89omwn1pxohihFg0DKc4eW6FoA=;
b=PMTioO7I4a87S0m3fOkx00kgyg99OzRJ51ZqK+/lILpAnKZMpDR3flvuhd1IRpZydA
bDy4XCQttYzs8gG5Ywxt6+p7JSBVAbJYl9anko3HamV6V6V48yxB+w3tII5vKVcPy1NB
2gpVix/+JCpYFv9/aCWeRrtLDGInDINR0dOid46g2pdJQ7gLTgc3fsG22jAUfVpPFufY
5dJvKMrFwnrQdg1fMY5j4PXrVSoCftk6EmAOxVAEsCCstf3NzEsGbIp82r9BOSskQbc3
8i4LKcShtn8jmfErFkAfKa6BQTIl7xVS43SYJ66/qIDUpFEUunaoBjEmwnx2UfytxFEm
8+tg==
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=W39KuADT3iwB6lsSd89omwn1pxohihFg0DKc4eW6FoA=;
b=ufOXV/1S5yMcGe6AtIlNCmVP0A3z7tMVAGDZ2XRTjLoCk8WFEovAshj4zPD501yEof
VF21fSRht1c/mi27OKVvPe8GvU0KUhwxtbEz1e3vsdtTa4kAP0VINr0LmGdDArobDhyF
tNuQq5rNrrri0n+2umHbCROOhzBJPyIbIgOnnYPOG58fZi7T6EupVu+N9oM+ETi2+4VG
n1hrAxpHHmKytV7Nk+rB+VDVHlXod+snszhiC/MtwcWgL3Wu9H/AzWuzVQO+KUCHQdRT
z78tvuq0YHuG4ExXwlhzLE/pTsSQ+BQD9DIGu53DkxQuz13E0Fcrp8ZfjH7kUid/TJNh
CBHw==
X-Gm-Message-State: AOAM53269v2jxgymFMNommWACRqAIYz+vPEYxvmooCLkdzYJeZwPudKs
GQBpVxLsmspRrFtOG3c7VC1SBV+FKptYS95LkdvshAlq5Q8F4g==
X-Google-Smtp-Source: ABdhPJw/rhMED0epq1f6pdiHdhro7W5mhMO/yQfc07Q+O2lA5q/krn4WTZRgFdGeT8Pd4ahqSXnDtD3+wGzTl6MD7MY=
X-Received: by 2002:a17:902:ce04:b0:156:3be:8a86 with SMTP id
k4-20020a170902ce0400b0015603be8a86mr5082424plg.152.1650146714317; Sat, 16
Apr 2022 15:05:14 -0700 (PDT)
In-Reply-To: <CAD+b3HgmWTbnSX0DT5T7uudOBTOiSFDMhzrOe87RqTU64bc9JQ@mail.gmail.com>
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: <CAD+b3Hg3hTs8HZGMs7WLdATP+BMWpyjJeqw3u_fxgE1b=hk5JA@mail.gmail.com>
X-Mailman-Original-References: <CAD+b3HgooPwsBw06+SOtc3S8d9-wFzjzS-CuQSoTeLGikcDvpQ@mail.gmail.com>
<e4dc2443-8ea4-b121-9ba2-0dc0ebc74723@DancesWithMice.info>
<CAD+b3HgmWTbnSX0DT5T7uudOBTOiSFDMhzrOe87RqTU64bc9JQ@mail.gmail.com>
 by: Sam Ezeh - Sat, 16 Apr 2022 22:05 UTC

> Perhaps I'm missing the point, but what functionality or advantage(s)
> does this give, over data-classes?

One advantage is maintaining control over the __init__ function
without having to write extra code to do so. In the linked discussion
from python-ideas, it was mentioned that keyword-only and
positional-only arguments can't be used with dataclasses [1].

> Maybe Dataclasses are not being used as much as one might hope, but they
> are relatively new, and many Python-Masters simply carry-on constructing
> classes the way they have for years...

I think one concern I have is that even if this is useful, it might
still fall to the same fate.

[1]: https://mail.python.org/archives/list/python-ideas@python.org/message/SCTXSEKOWDRDGVXXOEB7JUC6WE7XKGMO/

On Fri, 15 Apr 2022 at 22:30, dn <PythonList@danceswithmice.info> wrote:
>
> On 15/04/2022 23.19, Sam Ezeh wrote:
> ...
>
> Kudos for doing the research!
>
>
> > Some related implementations are attrs, dataclasses and the use of a
> > decorator. And there's potentially a point to be raised that the results
> > from the first query indicate that the @dataclasse decorator is not being
> > used enough. One advantage this proposal offers is control over the
> > arguments that the __init__ function takes.
> >
> > A downside to using a decorator is that it might become difficult to accept
> > arguments that don't need to be assigned to anything.
> >
> > I gave the example of the following code (unlike the above, this is not
> > taken from existing python source code). In this example, a decorator can't
> > assign all of the arguments to attributes or else it would produce code
> > that does something different.
> ...
>
>
> I will support anything which reduces 'boiler-plate' or 'make busy' work!
>
> Perhaps I'm missing the point, but what functionality or advantage(s)
> does this give, over data-classes?
>
> Maybe Dataclasses are not being used as much as one might hope, but they
> are relatively new, and many Python-Masters simply carry-on constructing
> classes the way they have for years...
>
> If data-classes give the impression of being 'syntactic sugar', there's
> no particular need to use them - and certainly no rule or demand.
>
> There are constructs where one might find it easier not to use them.
>
> @dataclass does allow init=False.
>
> There is an argument which says that all data-attributes should be
> 'created' inside an __init__() or __post_init__(), rather than
> 'somewhere', 'later'.
> --
> Regards,
> =dn
> --
> https://mail.python.org/mailman/listinfo/python-list


devel / comp.lang.python / Fwd: Proposal: Syntax for attribute initialisation in __init__ methods

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor