Python Forum
setting base class attribute - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: setting base class attribute (/thread-8296.html)



setting base class attribute - bb8 - Feb-13-2018

how can i ensure that an attribute can only be set from derived class? if some other class tries to set it, it should be illegal


RE: setting base class attribute - nilamo - Feb-13-2018

Please, give more information. What you're describing doesn't make sense for something you should need to worry about, as a parent object should never care what "extra" baggage derived/child classes add on. That's sort of the whole point of having derived classes, after all, adding functionality to a base class.