Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

The best way to accelerate a Macintoy is at 9.8 meters per second per second.


devel / comp.lang.python / Re: type annotation vs working code

SubjectAuthor
o Re: type annotation vs working codeKarsten Hilbert

1
Re: type annotation vs working code

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: Karsten....@gmx.net (Karsten Hilbert)
Newsgroups: comp.lang.python
Subject: Re: type annotation vs working code
Date: Sun, 1 Oct 2023 13:57:10 +0200
Lines: 63
Sender: <karsten.hilbert@gmx.net>
Message-ID: <mailman.376.1696161433.23016.python-list@python.org>
References: <ZRhwWN29i3mskxEL@hermes.hilbert.loc>
<ecc36615-1844-455f-b701-2bd41d98e9e1@DancesWithMice.info>
<ZRigRwHpNReUo5rF@hermes.hilbert.loc>
<4f1c9568-3850-4847-b357-740f79b0a79b@DancesWithMice.info>
<ZRlelmUwOR/wcPqR@hermes.hilbert.loc>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de TrcmYcFaxh+GD6reEfM/3gqohK0z6rHI5llJkigPNCZA==
Cancel-Lock: sha1:sQBgx2dcq2g/mzwYo11H+sSxtbY= sha256:ZdcTU50eMK020eYGMzeN9lm1PjiG618Vzy/LlDN4XDY=
Return-Path: <karsten.hilbert@gmx.net>
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=gmx.net header.i=karsten.hilbert@gmx.net
header.b=NoM54iWI; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.004
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'this:': 0.03; 'def': 0.04;
'achieved': 0.07; 'received:212.227': 0.07; 'tests': 0.07; ':-)':
0.09; 'borg': 0.09; 'gpg': 0.09; 'karsten': 0.09; 'question:':
0.09; '1713': 0.16; 'akin': 0.16; 'confusion': 0.16; 'dict': 0.16;
'eg:': 0.16; 'generating': 0.16; 'instance': 0.16;
'received:212.227.15': 0.16; 'subject:code': 0.16;
'subject:working': 0.16; 'problem': 0.16; 'to:addr:python-list':
0.20; 'skip:_ 10': 0.22; 'seems': 0.26; 'code,': 0.31; 'module':
0.31; 'language.': 0.32; 'but': 0.32; 'there': 0.33; 'core': 0.34;
'header:In-Reply-To:1': 0.34; "we're": 0.35; 'using': 0.37;
'class': 0.37; 'sorry': 0.60; "there's": 0.61; 'received:212':
0.62; 'true': 0.63; 'leading': 0.63; 'full': 0.64; 'matter': 0.68;
'skip:w 20': 0.69; '....': 0.76; 'supposed': 0.76; 'attribute':
0.84; 'conflated': 0.84; 'implies': 0.84; '...and': 0.91;
'subject:type': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=s31663417;
t=1696161431; x=1696766231; i=karsten.hilbert@gmx.net;
bh=/z2e09C0SwctXOz6snBE+10/PV24rHxB5nE83uGH/co=;
h=X-UI-Sender-Class:Date:From:To:Subject:References:In-Reply-To;
b=NoM54iWIvnyZi3JWwPAzaKI2AjtNal4EQACqkYDokDHJbfe3AfsolQPfssRqNtx4e3RchKTq1kK
Div7PCdpGh/V4MCgTZNV08KpUf8HDCSgkqKpT+LEzKw0seJob9W+I1MDjjjrJd8TeTKSM1dkKZalJ
V8NZ7HVFVCmFY5RquAP7EetfgFA0HvboqcRk9BGVwuaqPUCwYwf3AeVYWz4464YG+LX/5fdL+zYUU
tiCePPXFXQKxbhQwSJtzBK2h0+z6MJEq+lAecmwAD0eWD7e9FHu2Lgnx+7kT9slAxOEySzCarlG51
Sg/UJup/KuTOS7ItqIZBNoub87a8BaUpCSQQ==
X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a
Content-Disposition: inline
In-Reply-To: <4f1c9568-3850-4847-b357-740f79b0a79b@DancesWithMice.info>
Ma_X_il-Followup-to: d
Re_X_turn-receipt-to: Karsten.Hilbert@gmx.net
Di_X_sposition-Notification-To: Karsten.Hilbert@gmx.net
X-Confi_X_rm-Reading-To: Karsten.Hilbert@gmx.net
X-Pri_X_ority: 2 (High)
X-Provags-ID: V03:K1:exIun/DFBsbOyjvuESQio1J00U1z29ffp0zs4rxOuZPGrJ3Hal/
1Yu7nNjBY22CLP6ZTW7eo1iHOQzggkTCsnSfEJ4zglerMlYCofdy2hsQ1EnWF9C6SyaWkZA
E86PZyOcX4Ue2cTCVxtY4+cKtd2MLWJcXrywEptMpacSSryMy0FciJR6sVqRK4ZsiLl+VNj
wtIqSzpbqGvX2MwZum/1w==
X-Spam-Flag: NO
UI-OutboundReport: notjunk:1;M01:P0:sStCQp3SKtg=;YCSxHPZ+shBcIqbIw6kDKr1ZSUe
CFW9TTuKH0zSlHlBe367aCmdivpH1Iamxy6XzXkC8v7m05J4VPtw1sIcLBIxlaq0YR4zEcsWJ
TzXrckOX2NGZpjxieeuq6ZykebuCixw0vYxMsHOQYJK4SbAlPmhWYrkRBVGUyIM8RYhUsNOgm
miIWsx0xy20qJLXLgQ2K8M3r6slkA3Z6K16vrd/T8zZZT8dvHZv/sp8eS6zPDygJDV6aJsNGz
SHdPMGmYw+mQEYPN9n9zsUI6nXsU1isma5rQdU099R2w/sv0eW49I4HoTZagd/dIusfwkYJZr
Uf9wOrPaDbOY118fSeVNJ8sM1FsyfHuXXNR6WsYMIWE7m8kyKgcrmCHerub7SMEpZcvLruQvN
FnolwmSMh3JmHo6w0BsJb3uN2Pp5wExiyvnuTxBFk2sPJ4TR2Uk6DS1YSWRqaaG2d3lDYoZUc
Bj4K1+cIEqvt82k+jrm4/gl+aDYnOUixGMk9uBT3clTnaS2rJY3wLDFKqeepUD1I/auiM55/r
Ym2acEgoWnKuaY6b/JJe6Uk3HvLiRnpXzzruqv8yv89Mb9U2ZX7fkVvNaGZHwlRneBXPaZj2r
aA4M0Ljsh6wx6UigGPcsaDs8EN60eJz+l2nJhvMb5nu58xmyCOBLSfsU36AqzTAMZ2Q1GBx+d
F6zRM7epyDM63uI01qwzhqMP54JbBH/YiAuqW/+U7dAGZwyaT6jaiObkJh3kL/2AsWa8hreKB
08bzgMDMxAtutLmQNNNXA+Uw7yDr6Qv9YME/Mq3HDNyXF9Mk/sIhAKr78TBxXB0K/5ejHMPlS
kTV/n07oxbfVL95ewcgToZMxJix8xWj20E0kNC4EvaZEGGzpURM1z+u2/KgvZQ80pGQZTxuQZ
KOX42xOpP4mz5BWEA6vO63EtY8muDhjAgN8kwP/JK4dPMqLDs4AR2yPrekczGBbrsOfBr9GKn
KT2gO8waNaYdY10L1TKRwxfQAug=
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: <ZRlelmUwOR/wcPqR@hermes.hilbert.loc>
X-Mailman-Original-References: <ZRhwWN29i3mskxEL@hermes.hilbert.loc>
<ecc36615-1844-455f-b701-2bd41d98e9e1@DancesWithMice.info>
<ZRigRwHpNReUo5rF@hermes.hilbert.loc>
<4f1c9568-3850-4847-b357-740f79b0a79b@DancesWithMice.info>
 by: Karsten Hilbert - Sun, 1 Oct 2023 11:57 UTC

Sorry for having conflated the core of the matter with all
the Borg shenanigans, that's where I found the problem in my
real code, so there :-)

Consider this:

#----------------------------------------------------
class Surprise:
def __init__(self, with_type_annotation=False):
if with_type_annotation:
try:
self.does_not_exist:bool
print('does_not_exist does exist')
except AttributeError:
print('does_not_exist does not exist')
return

try:
self.does_not_exist
print('does_not_exist does exist')
except AttributeError:
print('does_not_exist does not exist')

Surprise(with_type_annotation = False)
Surprise(with_type_annotation = True)
#----------------------------------------------------

Is this how it is supposed to be ?

> ...and so we're addressing the important question: the try-test is for existence, cf for
> some value.
>
> This can also be achieved by using the attribute in a legal expression, eg:
....
> Might this remove the confusion (ref: @Mats):
>
> self.already_initialized:bool == True

Not for me as that would _create_ already_initialized on the
instance. It would not allow me to test for it.

> >Which seems akin constructs for generating compatibility
> >between versions.
>
> versions of ?

Of the language. Sometimes one tests for existence of a given
class in a module and defines said class oneself if it does
not exist. But that's leading astray.

> What is the intent: a class where each instance is aware of every other instance - yet
> the word "Singleton" implies there's only one (cf a dict full of ...)?

The latter.

Regards,
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor