Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

On the eighth day, God created FORTRAN.


devel / comp.lang.python / Re: Typing on child class' methods of a Generic base class

SubjectAuthor
* Re: Typing on child class' methods of a Generic base classDieter Maurer
`* Re: Typing on child class' methods of a Generic base classJulio Di Egidio
 `- Re: Typing on child class' methods of a Generic base classJulio Di Egidio

1
Re: Typing on child class' methods of a Generic base class

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: die...@handshake.de (Dieter Maurer)
Newsgroups: comp.lang.python
Subject: Re: Typing on child class' methods of a Generic base class
Date: Thu, 10 Mar 2022 18:31:11 +0100
Lines: 15
Message-ID: <mailman.262.1646933473.2329.python-list@python.org>
References: <3fccbe66-4d1c-f40c-7282-026ebe7360e3@boiteameuh.org>
<25130.13791.689201.429804@ixdm.fritz.box>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de d6kdQ+cZJhnhWxm8fOpB7gCjGbYg+RRo527w5pWQ5F3A==
Return-Path: <dieter@handshake.de>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.056
X-Spam-Evidence: '*H*': 0.89; '*S*': 0.00; 'class.': 0.07; 'cc:addr
:python-list': 0.09; 'child': 0.09; 'subject:class': 0.09; 'cc:no
real name:2**0': 0.14; 'nicolas': 0.16; 'setup,': 0.16; 'skip:>
10': 0.16; 'subject:child': 0.16; 'says': 0.17;
'cc:addr:python.org': 0.20; 'received:de': 0.23; '(and': 0.25;
'cc:2**0': 0.25; 'leave': 0.27; 'example,': 0.28; 'but': 0.32;
'header:In-Reply-To:1': 0.34; 'those': 0.36; 'class': 0.37; 'two':
0.39; 'use': 0.39; 'methods': 0.39; 'wrote': 0.39; 'follow': 0.62;
'key': 0.64; 'your': 0.64; 'types': 0.67; 'header:Received:6':
0.67; 'signature': 0.76; 'received:88': 0.84; 'signatures': 0.84;
'specialize': 0.93
In-Reply-To: <3fccbe66-4d1c-f40c-7282-026ebe7360e3@boiteameuh.org>
X-Mailer: VM 8.0.12-devo-585 under 21.4 (patch 24) "Standard C" XEmacs Lucid
(x86_64-linux-gnu)
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: <25130.13791.689201.429804@ixdm.fritz.box>
X-Mailman-Original-References: <3fccbe66-4d1c-f40c-7282-026ebe7360e3@boiteameuh.org>
 by: Dieter Maurer - Thu, 10 Mar 2022 17:31 UTC

Nicolas Haller wrote at 2022-3-9 10:53 -0500:
> ...
>The documentation about "user-defined generic types"[1] says that I can
>fix some types on a child class (class MyDict(Mapping[str, T]):) but
>doesn't say much about the signature of the methods I need to
>implement/override on that child class.

I have the fealing that this is a case of (generic type) "specialization".
In this setup, `Mapping` would be a generic type with two type
variables `K` (the key type) and `V` (the value type).
The signatures of its methods would use those type variables.
In your example, you specialize the key type to `str` (and
leave the value type generic). The signatures of the methods
would automatically follow this specialization -- without the need
to do anything.

Re: Typing on child class' methods of a Generic base class

<eed794eb-085f-45af-84f5-682893712a3bn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:a0c:d692:0:b0:432:3605:6192 with SMTP id k18-20020a0cd692000000b0043236056192mr5653709qvi.90.1646952624560;
Thu, 10 Mar 2022 14:50:24 -0800 (PST)
X-Received: by 2002:ac8:57d5:0:b0:2e0:70a8:4419 with SMTP id
w21-20020ac857d5000000b002e070a84419mr6108920qta.257.1646952624389; Thu, 10
Mar 2022 14:50:24 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Thu, 10 Mar 2022 14:50:24 -0800 (PST)
In-Reply-To: <mailman.262.1646933473.2329.python-list@python.org>
Injection-Info: google-groups.googlegroups.com; posting-host=93.41.97.2; posting-account=F3H0JAgAAADcYVukktnHx7hFG5stjWse
NNTP-Posting-Host: 93.41.97.2
References: <25130.13791.689201.429804@ixdm.fritz.box> <3fccbe66-4d1c-f40c-7282-026ebe7360e3@boiteameuh.org>
<mailman.262.1646933473.2329.python-list@python.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <eed794eb-085f-45af-84f5-682893712a3bn@googlegroups.com>
Subject: Re: Typing on child class' methods of a Generic base class
From: jul...@diegidio.name (Julio Di Egidio)
Injection-Date: Thu, 10 Mar 2022 22:50:24 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Julio Di Egidio - Thu, 10 Mar 2022 22:50 UTC

On Thursday, 10 March 2022 at 18:32:33 UTC+1, Dieter Maurer wrote:

> The signatures of the methods [in the derived class]
> would automatically follow this specialization -- without the need
> to do anything.

That depends entirely on the tools, typing in Python remains just
annotations. And I wouldn't do that anyway: the code in the derived
class without explicit annotations becomes simply opaque to
any typing (you just see it if you have intellisense or similar), and
readability is the most important and here almost the unique thing...

Julio

Re: Typing on child class' methods of a Generic base class

<3cfd3b77-33fc-48df-9a85-9321c7b633a7n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:ac8:7f82:0:b0:2e1:caba:ad6e with SMTP id z2-20020ac87f82000000b002e1cabaad6emr2514372qtj.190.1647117020039;
Sat, 12 Mar 2022 12:30:20 -0800 (PST)
X-Received: by 2002:a05:620a:709:b0:67c:85ef:711e with SMTP id
9-20020a05620a070900b0067c85ef711emr10296307qkc.173.1647117019868; Sat, 12
Mar 2022 12:30:19 -0800 (PST)
Path: i2pn2.org!rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Sat, 12 Mar 2022 12:30:19 -0800 (PST)
In-Reply-To: <eed794eb-085f-45af-84f5-682893712a3bn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=93.41.98.178; posting-account=F3H0JAgAAADcYVukktnHx7hFG5stjWse
NNTP-Posting-Host: 93.41.98.178
References: <25130.13791.689201.429804@ixdm.fritz.box> <3fccbe66-4d1c-f40c-7282-026ebe7360e3@boiteameuh.org>
<mailman.262.1646933473.2329.python-list@python.org> <eed794eb-085f-45af-84f5-682893712a3bn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <3cfd3b77-33fc-48df-9a85-9321c7b633a7n@googlegroups.com>
Subject: Re: Typing on child class' methods of a Generic base class
From: jul...@diegidio.name (Julio Di Egidio)
Injection-Date: Sat, 12 Mar 2022 20:30:20 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 17
 by: Julio Di Egidio - Sat, 12 Mar 2022 20:30 UTC

On Thursday, 10 March 2022 at 23:51:10 UTC+1, Julio Di Egidio wrote:
> On Thursday, 10 March 2022 at 18:32:33 UTC+1, Dieter Maurer wrote:
>
> > The signatures of the methods [in the derived class]
> > would automatically follow this specialization -- without the need
> > to do anything.
> That depends entirely on the tools, typing in Python remains just
> annotations. And I wouldn't do that anyway: the code in the derived
> class without explicit annotations becomes simply opaque to
> any typing (you just see it if you have intellisense or similar), and
> readability is the most important and here almost the unique thing...

P.S. Thanks whoever banned be from the Python list distribution and
without even telling me: very well done, another conquest for humanity.

*Plonk*

Julio

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor