0

I was wondering, if I do not create setters in my class definition, then essentially I can create an immutable object following the class model, right? What do you think? There might be other ways to go also.

stone stone
  • 75
  • 2
  • 10
  • No, you cannot because I can always add properties to an object of your class without at anytime. The question is why do you think you need a immutable object? – Burhan Khalid Nov 15 '17 at 03:13
  • can you give us some code and concepts you were kicking around? This might be something worth looking at: https://stackoverflow.com/questions/8056130/immutable-vs-mutable-types – Fallenreaper Nov 15 '17 at 03:15
  • This has been answered here: https://stackoverflow.com/questions/4996815/ways-to-make-a-class-immutable-in-python – Brian Wright Nov 15 '17 at 03:15
  • 3
    Possible duplicate of [How to make an immutable object in Python?](https://stackoverflow.com/questions/4828080/how-to-make-an-immutable-object-in-python) – Patrick Haugh Nov 15 '17 at 03:17

0 Answers0