Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #422: Someone else stole your IP address, call the Internet detectives!


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

SubjectAuthor
o RE: super().__init__() and bytesAnders Munch

1
Subject: RE: super().__init__() and bytes
From: Anders Munch
Newsgroups: comp.lang.python
Date: Tue, 3 Dec 2024 12:55 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: ajm@flonidan.dk (Anders Munch)
Newsgroups: comp.lang.python
Subject: RE: super().__init__() and bytes
Date: Tue, 3 Dec 2024 12:55:59 +0000
Lines: 16
Message-ID: <mailman.5.1733230566.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>
Mime-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64
X-Trace: news.uni-berlin.de vXMol5tgYBpbhV5R0UaVcg81dv18jDNumkiMcZnfYRaQ==
Cancel-Lock: sha1:2H2UJ80a4n/jDacm1qsMZKU5+40= sha256:EQoCtFADO8/bN8B5M1mrcQBNPftAdtxOAXRrM6O/av4=
Return-Path: <ajm@flonidan.dk>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="1024-bit key; unprotected key"
header.d=FlonidanAS.onmicrosoft.com header.i=@FlonidanAS.onmicrosoft.com
header.b=JtgmerxM; dkim-adsp=none (unprotected policy);
dkim-atps=neutral
X-Spam-Status: OK 0.008
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'looks': 0.02; 'def': 0.04;
'int': 0.09; 'roel': 0.09; 'schroeven': 0.09; 'yes.': 0.09;
'that.': 0.15; 'nothing,': 0.16; 'subject:() ': 0.16;
'subject:super': 0.16; 'wrote:': 0.16; 'to:addr:python-list':
0.20; 'all,': 0.20; 'to:name:python-list@python.org': 0.24;
'cannot': 0.25; 'behavior': 0.26; 'takes': 0.31; "doesn't": 0.32;
'but': 0.32; 'header:In-Reply-To:1': 0.34; 'work,': 0.36;
'change': 0.36; 'using': 0.37; "it's": 0.37; 'class': 0.37; 'use':
0.39; 'define': 0.40; 'something': 0.40; 'tell': 0.60; 'best':
0.61; 'method': 0.61; 'skip:o 10': 0.61; 'skip:b 20': 0.63;
'skip:b 10': 0.63; 'inherited': 0.84
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
b=i7bvGRlm+DfIlps1dXwvra59D4P+qvbRdP2UX763Wj5YqxnOC5DMed97HFFQBcVV6eHSt8JVAWg5PqjS7yj0PA7Uok4I36ddHT9KQiC21oPGoD9GwvY6RcUKfdNHzykcw+kR9M70gpCPzqoUsq2Ljk5DrdMTPJd+uc30miMfNhj05ArZ+pbmx+egdT0vffEyz/QQ7nYx2hvfCNRnmzw2gTod+wyrkhaTta0RQ9brG4+X70Mc9IzBAc+nHV1BQa9qrEBVg8YUXOqRTebFANGY+IrA6ejQRUfU9U/ospZrh0vQaxgjk5zDRBYcNVyWVqrYfV+eQqFviY0bsGwLPObcRQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
s=arcselector10001;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
bh=s5dPT23SrKNnTXf0K1O9HwMizCnouIw94mGr+xYWIB0=;
b=tLLFbTDB2hWfygY18qR87N3OMs20bUYFwKXww4ontu6QJOrlajmHlXHkADBHfQudzymsl76b0t9ZjHEt2Ke7MbzYF9wXi/8q0sQJO869BPrjay9bWbCF4ceFlEa+InfCLL33Qj6LA5uGY0rCGvVj9SrKPoVDi/tf+LCejkbmutWOr+rY1kf3jnsk88+qaN/O20Uirl6pO0BOaox7BK+cItvdUlFj0JQgSnEKgv9CystuBOzig8NkO4dmDdW5JtlcH64YsLkzTyIN0dW8LSBM+vlEMhsSJIxGPgCTJzTvL5qgjj2GA5gSigwptAiUFXV0qUPICH/6RurMwsGqgjAO4Q==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
smtp.mailfrom=flonidan.dk; dmarc=pass action=none header.from=flonidan.dk;
dkim=pass header.d=flonidan.dk; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=FlonidanAS.onmicrosoft.com; s=selector2-FlonidanAS-onmicrosoft-com;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
bh=s5dPT23SrKNnTXf0K1O9HwMizCnouIw94mGr+xYWIB0=;
b=JtgmerxMX9WRSJUPHb+6XW89lWwohPHb+xF8I5QsubQwdNEqEZrMuJZU5kKntwZOU8gFas73cCgvUf9JMhqHJW846JGzHTiQFxov8icKXs6cFzKxjYBreHT71qsmaa82kuXsvaxfEuaPPaGMvlCXKUVf7in+Y5A1L1SUHSUSRhs=
Thread-Topic: super().__init__() and bytes
Thread-Index: AQHbRWfQ7sZ9Za+rakGdleVqBAorgLLUSbIAgAAoy8A=
In-Reply-To: <ce4e0a1b-229a-48ad-b256-5835e0e509cc@roelschroeven.net>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
authentication-results: dkim=none (message not signed)
header.d=none;dmarc=none action=none header.from=flonidan.dk;
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: VI1PR05MB10680:EE_|GV1PR05MB11314:EE_
x-ms-office365-filtering-correlation-id: 704c3ac9-60b1-4088-0583-08dd1399d628
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam: BCL:0; ARA:13230040|376014|1800799024|366016|38070700018;
x-microsoft-antispam-message-info: Ij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5B6RvS+41jBtmwTrq2mxRvZynvTY0A+Po
YxwoKxvYCsgV4YQAqorIxsm6LT56mdBj1QHRSQZixcZgS
EppAXih48sDFzGSgF8Oy7tpQOa0fPYe2bYa/WkcujSj6n
9d/ecM3ZhQbZso8anZN2TM4fouJTZjOqx5iMe4guiVB8k
GtCBJgC/eT31SvxvYwgCSacUy/tnznoG2Ws+kYXo/DZHX
n+F9FLfPbPI3Z52BXaiVmFaL329I2xBFwA/UKwTArFOZ4
Nq6opnsvRsTYf+wamgZr/doCuJw6LQ/nl2B/24UkelbdZ
b5KKO9w/F2DfdlVGYEGW4tDeQisAs4GmIEP8m3rQ2tqEu
QKJQTxazqQvorlrIpM+S51d+6kbvWaKQS6g==
x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;
IPV:NLI; SFV:NSPM; H:VI1PR05MB10680.eurprd05.prod.outlook.com; PTR:; CAT:NONE;
SFS:(13230040)(376014)(1800799024)(366016)(38070700018); DIR:OUT; SFP:1102;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0: S+hYmPZFsEzIa8A62ML1UtfTDkpa3bqoZQ2zrNYhFG7eS
laeULWgebw+TpYfghFn2h3yad5CSz+iNQPyM/41kYXz5n
C21V9DJDMyAH1IuXSKOJjr1EbDH0ZfO4sYGjOHZMfDjdt
5hJKRI0zrsc/dN5FwJuMlhXRs7nffl/4ik6vmAi0agDI/
hP31vLotPQnRJlpW4LW+44XOx655gGjE/77HX56k0SLs1
U7fv2OPVp4YX8JKbCp+9zmCLcO/+Bs9IrPM8WQqtyiZvs
tbLnkaDReDVkVX41hlSqYFTgGFarAu3NoY3MlO7sSa5H5
eiAMWjVjkVwgcXUNpfuqJk/2aLzFj+p+3oqMzbySSMEQD
KZf6vxDc3ozhmnBu9rtoxKENdQkEnpTeMTQ20CL4kajLc
i9PpCTxpkhV5GzSH1bCpI67hKgL2mjpl7/pX4bBkTDh/u
ZQ8PNT44EuBf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H74OoGxEI9UYgKT9ZhW
5Am51GEVjfHu+3TFeKB42FvSfoeZjokLTKDModH7Vt+/H
87f0=
X-OriginatorOrg: flonidan.dk
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: VI1PR05MB10680.eurprd05.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 704c3ac9-60b1-4088-0583-08dd1399d628
X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Dec 2024 12:55:59.9722 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 66f919b0-b207-4d78-ae72-d81c18f86ec5
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: f2c6c7rZB5pVnT8nBLjIYi2oUGTIXpDN/pwSHpNYmm5nCFVD88ulBQiD5BK958iD
X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR05MB11314
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: <VI1PR05MB106809E93AA17A3D46E380DFEB4362@VI1PR05MB10680.eurprd05.prod.outlook.com>
X-Mailman-Original-References: <3cc6272f-b151-474a-a83c-7f3339734bf5@roelschroeven.net>
<ce4e0a1b-229a-48ad-b256-5835e0e509cc@roelschroeven.net>
View all headers

Roel Schroeven <roel@roelschroeven.net> wrote:
> As a follow-up, it looks like this behavior is because bytes and int are immutable.
Yes.
> 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.
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
regards,
Anders

1

rocksolid light 0.9.8
clearnet tor