Making immutable instances

bonono at gmail.com bonono at gmail.com
Thu Nov 24 10:01:16 CET 2005


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.




More information about the Python-list mailing list