def __init__(self):
Random832
random832 at fastmail.com
Tue Apr 26 12:26:07 EDT 2016
On Tue, Apr 26, 2016, at 12:12, Steven D'Aprano wrote:
> The obvious reason for overriding __new__ is to construct an immutable
> instance. You have to override __new__, because by the time it returns
> the
> instance is immutable and you can no longer initialise it.
Other than by subclassing an existing immutable type written in C, is it
actually possible to define a truly-immutable (rather than
contract-immutable) class in python?
(Of course, subclassing immutable C types is the more obvious answer to
when you have to override __new__).
More information about the Python-list
mailing list