Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #169: broadcast packets on wrong frequency


comp / comp.lang.python / Re: super().__init__() and bytes

SubjectAuthor
* Re: super().__init__() and bytesRoel Schroeven
`* Re: super().__init__() and bytesGreg Ewing
 `- Re: super().__init__() and bytesRoel Schroeven

1
Subject: Re: super().__init__() and bytes
From: Roel Schroeven
Newsgroups: comp.lang.python
Date: Tue, 3 Dec 2024 14:24 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: roel@roelschroeven.net (Roel Schroeven)
Newsgroups: comp.lang.python
Subject: Re: super().__init__() and bytes
Date: Tue, 3 Dec 2024 15:24:55 +0100
Lines: 39
Message-ID: <mailman.6.1733235899.2965.python-list@python.org>
References: <3cc6272f-b151-474a-a83c-7f3339734bf5@roelschroeven.net>
<ce4e0a1b-229a-48ad-b256-5835e0e509cc@roelschroeven.net>
<VI1PR05MB106809E93AA17A3D46E380DFEB4362@VI1PR05MB10680.eurprd05.prod.outlook.com>
<c5901834-52b0-4238-bda1-6b74220be68d@roelschroeven.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de 5667pQap5Rz/AkYQpmN+gwNgB1ckjS0IW5NfHR7vTFtA==
Cancel-Lock: sha1:/RcXiV5jbfKaF8eU2h6mtQ70hJU= sha256:pFUtBMLF80lJow+ZhNv2NbnEXS0f5EHlvx2bKgB6yiE=
Return-Path: <roel@roelschroeven.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=roelschroeven.net header.i=@roelschroeven.net
header.b=JaCL38NF; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.001
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'looks': 0.02; 'def': 0.04;
'attract': 0.09; 'int': 0.09; 'perfectly.': 0.09; 'roel': 0.09;
'schroeven': 0.09; 'yes.': 0.09; 'that.': 0.15; '"there': 0.16;
'attributes': 0.16; 'low-level': 0.16; 'nothing,': 0.16; 'ok.':
0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16;
'received:internal': 0.16; 'received:messagingengine.com': 0.16;
'schreef': 0.16; 'subject:() ': 0.16; 'subject:super': 0.16;
'terribly': 0.16; 'wrote:': 0.16; "can't": 0.17; 'to:addr:python-
list': 0.20; 'all,': 0.20; 'language': 0.21; "what's": 0.22;
'cannot': 0.25; 'behavior': 0.26; 'classes': 0.26; 'do,': 0.26;
'object': 0.26; "isn't": 0.27; 'think': 0.29; 'header:User-
Agent:1': 0.30; 'takes': 0.31; 'before.': 0.31; "doesn't": 0.32;
'but': 0.32; "i'm": 0.33; 'header:In-Reply-To:1': 0.34; 'same':
0.34; "didn't": 0.34; 'trying': 0.35; 'cases': 0.36; 'work,':
0.36; 'thanks,': 0.36; 'change': 0.36; 'necessarily': 0.37;
'special': 0.37; 'using': 0.37; "it's": 0.37; 'class': 0.37;
'though': 0.37; 'way': 0.38; 'use': 0.39; "that's": 0.39; 'on.':
0.39; 'define': 0.40; 'something': 0.40; 'want': 0.40; 'tell':
0.60; 'best': 0.61; 'method': 0.61; 'skip:o 10': 0.61; 'feel':
0.63; 'skip:b 20': 0.63; 'skip:b 10': 0.63; 'clear': 0.64;
'inherited': 0.84; 'method,': 0.84; 'received:103': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
roelschroeven.net; h=cc:content-transfer-encoding:content-type
:content-type:date:date:from:from:in-reply-to:in-reply-to
:message-id:mime-version:references:reply-to:subject:subject:to
:to; s=fm3; t=1733235896; x=1733322296; bh=mQLj9K/a3bhM32gthhmQM
hjptUbc0WEcBF+F3m9v8FQ=; b=JaCL38NFLVSrIQAjFHLmsz+GFVuoRIAAjMZA2
n9i6w/OBDqzqiz20efgX4qVhb4O/oXnkAAKVjvgchGA09/vbbcxKaUYV4KhQdoSM
ZrCSuYObe8iKDPLuBkXs27Bn6eciWwaLv3M8FOd1RhC3WPS2Epwh2gMMoAMGlZY3
VCnfYkvEF1aemejIbzpr2ALxJ/gJPKh2yAojtKUnj8TTFLuQWW9z4zkRx7VLNPao
/Cm3ShVkkUnpZ5Oew3z3HTKp8Mw6hjo2fDtkDJsBlVJydwiZ/JGFDtv/xu0R6IXI
RyW/KN0xFBPvPRRJw54QQ1gTGPidgzhLvuJoECX6728BXRkDg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
messagingengine.com; h=cc:content-transfer-encoding:content-type
:content-type:date:date:feedback-id:feedback-id:from:from
:in-reply-to:in-reply-to:message-id:mime-version:references
:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender
:x-me-sender:x-sasl-enc; s=fm1; t=1733235896; x=1733322296; bh=m
QLj9K/a3bhM32gthhmQMhjptUbc0WEcBF+F3m9v8FQ=; b=bum7s8hZ+fm7ZIcEX
/m8QOQJZVW4xpj1W110fXSPoMw4KwrOl7PxHse+io0OGG5btwrWBpLSZ81fqi3PI
Gel8kFZL8zxpZucNP3GH58a1Tw1Uqq6ziINe9YBFXrlGLxcKIsKdKHoe2vyr8hs7
i/a6Z56YQexTTb8ei5t5N+HHUKz39BhhAztqOyU/EMR+BK86Unb0V1qfa4q7FNde
q7TxGdmcb7WX8+lbT2F3ZEgsiLhLZ1kkHylaIKIm/OWpA+hjHk4VpHEiHLps1tlN
RwX472roZntpBnaSaklRxwkAsjPphVrUKPOpvsmoJ57AumQBcZEu5ytk/6UgiCyu
smgzQ==
X-ME-Sender: <xms:uBRPZ5fp3PaDeyzSkXdBgXQRHZgkOX6v6y-6DdwYcMIxLUq0yX1lUg>
<xme:uBRPZ3M7Fyf0rjjxbxHa30c-eONAVGy4IIlhFVnfPMrN6qx0qiI1BBEaluiKMQIfS
MwY1a8uzh-O>
X-ME-Received: <xmr:uBRPZyj6sQOoICfP776p-wFrO7R7rwblhUFe_0ngBX7ljoRC_lh_yuoveVRCs79Ji1FMSW_v6ra9q5yW4FRAwwsnMxer3ce1T7EqiVrFeJHIPH0>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrieefgdefhecutefuodetggdotefrodftvf
curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr
tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhepkfffgggfuf
fvfhfhjggtgfesthejredttddvjeenucfhrhhomheptfhovghlucfutghhrhhovghvvghn
uceorhhovghlsehrohgvlhhstghhrhhovghvvghnrdhnvghtqeenucggtffrrghtthgvrh
hnpeekgfefudeuhedvkeefjeehvdeljeelfffhtdegteejtdeufeeffefhveetudffueen
ucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrohgvlh
esrhhovghlshgthhhrohgvvhgvnhdrnhgvthdpnhgspghrtghpthhtohepuddpmhhouggv
pehsmhhtphhouhhtpdhrtghpthhtohepphihthhhohhnqdhlihhsthesphihthhhohhnrd
horhhg
X-ME-Proxy: <xmx:uBRPZy_fSguXgvMKT8oJgMdTwAXwmxeDkVQOVhp7JDOBCxywi0FSpA>
<xmx:uBRPZ1sF_dARPj_vRCg4cLZq9tpgMTN0ilA_ZvE4Q9ybdKeM3z2IHA>
<xmx:uBRPZxGmVal-7fKYgC30SKD0mIZg1h_OY2D28oEpOUsGTcmzKy6NmQ>
<xmx:uBRPZ8OM9FRdiBy840RTJ_Keq-LpGO2jLy__47DkCB8SmDFU3Kqrcw>
<xmx:uBRPZ2UBZ4O0c8kiesTd6aXacYPH8e83LzyeyP7ZzKo4-dr6C4L1Wv9H>
Feedback-ID: i8e5b41ae:Fastmail
User-Agent: Mozilla Thunderbird
Content-Language: nl, en-US
In-Reply-To: <VI1PR05MB106809E93AA17A3D46E380DFEB4362@VI1PR05MB10680.eurprd05.prod.outlook.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: <c5901834-52b0-4238-bda1-6b74220be68d@roelschroeven.net>
X-Mailman-Original-References: <3cc6272f-b151-474a-a83c-7f3339734bf5@roelschroeven.net>
<ce4e0a1b-229a-48ad-b256-5835e0e509cc@roelschroeven.net>
<VI1PR05MB106809E93AA17A3D46E380DFEB4362@VI1PR05MB10680.eurprd05.prod.outlook.com>
View all headers

Op 3/12/2024 om 13:55 schreef Anders Munch via Python-list:
> Roel Schroeven <roel@roelschroeven.net> wrote:
> > As a follow-up, it looks like this behavior is because bytes and int are immutable.
>
> Yes.
OK.
> > But that doesn't tell me why using super().__init__(<custom arguments>) doesn't work for immutable classes.
>
> bytes.__init__ does work, but it's just an inherited object.__init__, which does nothing, and takes no parameters.
> __init__ cannot change the value of the bytes object; the value is set by bytes.__new__ and cannot change after that.

I see now why __init__, being a regular method, can't change an object's
value (or attributes in general) if that object is immutable. I'm not
sure why I didn't think of that before.

It's not entirely clear to me though how bytes.__new__ *can* set an
object's value. Isn't __new__ also a regular function? Are these
immutable classes special cases in the language that can't be recreated
in the same way with user-defined classes? Not that that's something I
want to do, and it's also not terribly important to me, but I'm trying
to better understand what's going on.
> Best not to define an __init__ method at all, just use __new__.
>
> Something like:
>
> class BytesSubclass(bytes):
> def __new__(cls, whatever, arguments, you, like):
> bytesvalue = compute(whatever, arguments, you, like)
> ob = bytes.__new__(cls, bytesvalue)
> ob.some_other_att = compute_something_else(whatever, arguments, you, like)
> return ob
Thanks, that works perfectly. That's also more important than
understanding all the nitty-gritty details (I feel a basic understanding
is important, but not necessarily always all the low-level details).

--
"There is no cause so noble that it will not attract fuggheads."
-- Larry Niven

Subject: Re: super().__init__() and bytes
From: Greg Ewing
Newsgroups: comp.lang.python
Date: Tue, 3 Dec 2024 23:14 UTC
References: 1 2 3 4 5
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: greg.ewing@canterbury.ac.nz (Greg Ewing)
Newsgroups: comp.lang.python
Subject: Re: super().__init__() and bytes
Date: Wed, 4 Dec 2024 12:14:17 +1300
Lines: 11
Message-ID: <lr9hm9F77vdU1@mid.individual.net>
References: <3cc6272f-b151-474a-a83c-7f3339734bf5@roelschroeven.net>
<ce4e0a1b-229a-48ad-b256-5835e0e509cc@roelschroeven.net>
<VI1PR05MB106809E93AA17A3D46E380DFEB4362@VI1PR05MB10680.eurprd05.prod.outlook.com>
<c5901834-52b0-4238-bda1-6b74220be68d@roelschroeven.net>
<mailman.6.1733235899.2965.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net Es60DR8UJPOrEE9aWlskggFTDtXCIMIlf4N7c8dMYTHhNb3TyZ
Cancel-Lock: sha1:tqyqtoRmOtsURofQU4uUdp0ZCJo= sha256:bmKVM93iU0OkVRfUH+iLBRMbhtCUSXCg3d/5qHbkAWE=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:91.0)
Gecko/20100101 Thunderbird/91.3.2
Content-Language: en-US
In-Reply-To: <mailman.6.1733235899.2965.python-list@python.org>
View all headers

On 4/12/24 3:24 am, Roel Schroeven wrote:
> It's not entirely clear to me though how bytes.__new__ *can* set an
> object's value. Isn't __new__ also a regular function?

Yes, but the __new__ methods of the builtin immutable objects (int,
str, bytes, etc.) are implemented in C, and so are able to do things
that Python methods cannot.

--
Greg

Subject: Re: super().__init__() and bytes
From: Roel Schroeven
Newsgroups: comp.lang.python
Date: Wed, 4 Dec 2024 11:38 UTC
References: 1 2 3 4 5 6 7
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: roel@roelschroeven.net (Roel Schroeven)
Newsgroups: comp.lang.python
Subject: Re: super().__init__() and bytes
Date: Wed, 4 Dec 2024 12:38:33 +0100
Lines: 18
Message-ID: <mailman.10.1733312315.2965.python-list@python.org>
References: <3cc6272f-b151-474a-a83c-7f3339734bf5@roelschroeven.net>
<ce4e0a1b-229a-48ad-b256-5835e0e509cc@roelschroeven.net>
<VI1PR05MB106809E93AA17A3D46E380DFEB4362@VI1PR05MB10680.eurprd05.prod.outlook.com>
<c5901834-52b0-4238-bda1-6b74220be68d@roelschroeven.net>
<mailman.6.1733235899.2965.python-list@python.org>
<lr9hm9F77vdU1@mid.individual.net>
<b688c6ff-dc65-4649-9064-f0b6d0a90d94@roelschroeven.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de 7MnghdafiHgJdHwfThKz5Qdjm5E4xUbxKPSFaxdI4wUw==
Cancel-Lock: sha1:EwjwYRpc/PMQLzqmcSUTtc8x7/E= sha256:Eh+S95SsdEJ5eCi6XyyXIE9VuoV80xWlimDh0enePGk=
Return-Path: <roel@roelschroeven.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=roelschroeven.net header.i=@roelschroeven.net
header.b=ltUgMmX2; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.013
X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'confirming': 0.09; 'roel':
0.09; 'schroeven': 0.09; 'window.': 0.09; 'that.': 0.15; '"in':
0.16; 'builtin': 0.16; 'explaining': 0.16; 'greg': 0.16;
'received:10.202': 0.16; 'received:10.202.2': 0.16;
'received:10.202.2.163': 0.16; 'received:internal': 0.16;
'received:messagingengine.com': 0.16; 'schreef': 0.16; 'subject:()
': 0.16; 'subject:super': 0.16; 'wrote:': 0.16; 'python': 0.16;
'to:addr:python-list': 0.20; "wasn't": 0.26; "isn't": 0.27; 'old':
0.27; 'header:User-Agent:1': 0.30; 'am,': 0.31; 'objects': 0.32;
'technology,': 0.32; 'window': 0.32; 'but': 0.32; 'header:In-
Reply-To:1': 0.34; 'able': 0.34; 'same': 0.34; 'yes,': 0.35;
"it's": 0.37; 'though': 0.37; 'thanks': 0.39; "that's": 0.39;
'methods': 0.39; 'skip:b 10': 0.63; 'me.': 0.64; 'clear': 0.64;
'days,': 0.69; 'received:202': 0.69; 'writers': 0.69; 'front':
0.70; 'implemented': 0.76; 'sure.': 0.84; 'adams': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
roelschroeven.net; h=cc:content-transfer-encoding:content-type
:content-type:date:date:from:from:in-reply-to:in-reply-to
:message-id:mime-version:references:reply-to:subject:subject:to
:to; s=fm3; t=1733312312; x=1733398712; bh=hVjpma3bmFqtQY+vLHS14
dyih9buW1c7BZBAuF73DL4=; b=ltUgMmX2pKEDsN7hpgVx2etxpOxwgz9iwd6fV
WHJjl0BCJPw7TOZRgO7PdYW4Nyashv820/z/Y8ot7+rsPwPW0Ho10+ZbWS+xX7QW
AQtpoy8nJKszA0qRTLtMIFzNxu2qO3Jsgda1hiIYCCJ3d5GX+CRH8U1Jsv0hDjPx
FyNS0lWhh0ENZWVXQTNXdAZXPhPxo+RzbfnivG0fEXRlTx0r3scK9dIe+7/iq5hi
UbS/xQutLG6ngikeAQDN91uIzAFCg3bbuHKy3pI+z8LT5r3w+m+hdJ4bjdR4AFwS
0yuztAeQNaltxI9VlMv4BT35VdhT4IHMuoytStEk6Zf6xuVCA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
messagingengine.com; h=cc:content-transfer-encoding:content-type
:content-type:date:date:feedback-id:feedback-id:from:from
:in-reply-to:in-reply-to:message-id:mime-version:references
:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender
:x-me-sender:x-sasl-enc; s=fm1; t=1733312312; x=1733398712; bh=h
Vjpma3bmFqtQY+vLHS14dyih9buW1c7BZBAuF73DL4=; b=X7ru5dQIs06t6tUId
2BCBQT1l8Hxwp3RwHjewsMZERAWSHcdFk416sfAavH7G0FMS00im5qvRauyijJd1
GkYerWlTdGSfuYtU6B1lEIxBqCR23xAxNJ5M/5pdFMcSKw8cveal2FB0qPpa4FFh
CnaP35C6Lx3Fb0HIW5UXmhR88tHoW1JPNhmX9wv5IIcxTp9USrTlHyZM5r2H92wo
ukhn2AKYaWE4XQxiphKSgyoe0EAG8R2zyw3ZX1ztNFt4oT6Zf19Y+15ZUxRM1ZNc
q95aQl9rDT7O7Ar4omckG61Ps2r+zN8g5IvkPFK36bhl72y9ubs6GIeZSon9qydE
S2Scg==
X-ME-Sender: <xms:Nz9QZ4CbhZI4qS8GfFnQl0hfB0DDZCIPMa6pyJ6aizYUUITPe0wjbQ>
<xme:Nz9QZ6hRjg50ARHElsgR105w79sCM4BMvypmgdsn38j_G9Z5sCsei6CH_YQBTSteV
Vc4z0aTRcjj>
X-ME-Received: <xmr:Nz9QZ7kMNv4YNfFvkqYp7cHNSjACVwOYb2TK7GzzFtcFPBwFxVGiCM2grnR8aFlazD_JRyMqjmjdQdS_y8j1VX6ERIyktW4>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrieehgddvjecutefuodetggdotefrodftvf
curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr
tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhepkfffgggfuf
fvfhfhjggtgfesthekredttddvjeenucfhrhhomheptfhovghlucfutghhrhhovghvvghn
uceorhhovghlsehrohgvlhhstghhrhhovghvvghnrdhnvghtqeenucggtffrrghtthgvrh
hnpeegjeffkeegvdevjeejhfegtddvhefhiefhleefhffgiedtvdeigeeiieegvdduhfen
ucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrohgvlh
esrhhovghlshgthhhrohgvvhgvnhdrnhgvthdpnhgspghrtghpthhtohepuddpmhhouggv
pehsmhhtphhouhhtpdhrtghpthhtohepphihthhhohhnqdhlihhsthesphihthhhohhnrd
horhhg
X-ME-Proxy: <xmx:Nz9QZ-wM4Tm94U4u9_CRmb9sdBdtfjVWcNUxrQraHvdVpuTDWfzbfA>
<xmx:Nz9QZ9RMQqTZ-dZEvmNAEs7UJKvf94-1bY_QUUpGca0BF6R1GzNYUA>
<xmx:Nz9QZ5bKl60SwjFVEjBeBK3vojX9U5FGPJb67xilN9u7SArPAnn-fQ>
<xmx:Nz9QZ2SXiZI7lhw44ekGOElE5Fccug8D3qlSr1wCfEII9J0_Dt3omw>
<xmx:OD9QZ8JJfMoyxzkt5MVt_oAeG1cym32al9B-mEwp4FoiCIOMdVXX8cOI>
Feedback-ID: i8e5b41ae:Fastmail
User-Agent: Mozilla Thunderbird
Content-Language: nl
In-Reply-To: <lr9hm9F77vdU1@mid.individual.net>
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: <b688c6ff-dc65-4649-9064-f0b6d0a90d94@roelschroeven.net>
X-Mailman-Original-References: <3cc6272f-b151-474a-a83c-7f3339734bf5@roelschroeven.net>
<ce4e0a1b-229a-48ad-b256-5835e0e509cc@roelschroeven.net>
<VI1PR05MB106809E93AA17A3D46E380DFEB4362@VI1PR05MB10680.eurprd05.prod.outlook.com>
<c5901834-52b0-4238-bda1-6b74220be68d@roelschroeven.net>
<mailman.6.1733235899.2965.python-list@python.org>
<lr9hm9F77vdU1@mid.individual.net>
View all headers

Op 4/12/2024 om 0:14 schreef Greg Ewing via Python-list:
> On 4/12/24 3:24 am, Roel Schroeven wrote:
>> It's not entirely clear to me though how bytes.__new__ *can* set an
>> object's value. Isn't __new__ also a regular function?
>
> Yes, but the __new__ methods of the builtin immutable objects (int,
> str, bytes, etc.) are implemented in C, and so are able to do things
> that Python methods cannot.
Aha, yes, that's what I already suspected, but I wasn't sure. Thanks for
confirming that.

All clear now. Thanks to Anders and Greg for explaining this to me.

"In the old days, writers used to sit in front of a typewriter and stare out of
the window. Nowadays, because of the marvels of convergent technology, the thing
you type on and the window you stare out of are now the same thing.”
-- Douglas Adams

1

rocksolid light 0.9.8
clearnet tor