Making immutable instances

Mike Meyer mwm at
Thu Nov 24 17:32:35 CET 2005

"bonono at" <bonono at> writes:
> Mike Meyer wrote:
>> "Giovanni Bajo" <noway at> writes:
>> > Mike Meyer wrote:
>> >> Note that this property of __slots__ is an implementation detail. You
>> >> can't rely on it working in the future.
>> > I don't "rely" on it. I just want to catch bugs in my code.
>> I certainly hope you're not relying on it to catch bugs. You should do
>> proper testing instead. Not only will that catch pretty much all the
>> bugs you mention later - thus resolving you of the need to handcuff
>> clients of your class - it will catch lots of other bugs as well.
> That is an ideal case and we all know the real world is not ideal or
> every program would be bug free. And I don't think anyone would solely
> relies on the language feature for spotting bugs. Whether this kind of
> guard is useful is another story.

Python generally regards languages features that either require extra
typing or reduce the flexibility of the language for the purpose of
catching bugs as "not useful." Some people disagree with this, but
it's the way Python is.

Mike Meyer <mwm at>
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.

More information about the Python-list mailing list