Making immutable instances
mwm at mired.org
Thu Nov 24 17:32:35 CET 2005
"bonono at gmail.com" <bonono at gmail.com> writes:
> Mike Meyer wrote:
>> "Giovanni Bajo" <noway at sorry.com> 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 mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
More information about the Python-list