Sujet : Re: super().__init__() and bytes
De : roel (at) *nospam* roelschroeven.net (Roel Schroeven)
Groupes : comp.lang.pythonDate : 04. Dec 2024, 12:38:33
Autres entêtes
Message-ID : <mailman.10.1733312315.2965.python-list@python.org>
References : 1 2 3 4 5 6 7
User-Agent : Mozilla Thunderbird
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