Hacker News new | ask | show | jobs
by yes_or_gnome 3213 days ago
You can get close. Set __slots__ and then define each as a property with no setter and no deleter. However, an object can still be modified if it stores a mutable object (list, dict) and, while I'm not in front of a computer atm,I believe you can overwrite __slots__ to do whatever.

Here's an SO answer that explains more than I'll ever know about slots. https://stackoverflow.com/questions/472000/usage-of-slots

1 comments

Re: storing mutable objects, yea but tuples do that too:

    t = ({}, 1)
    t[0]['foo'] = 'bar'