On Tue, Dec 13, 2016 at 1:34 AM, Thomas 'PointedEars' Lahn <pointede...@web.de> wrote: > ³ How can one tell the difference in Python between a pre-initialized, > inherited attribute value and one own that is just equal to the inherited > one? In ECMAScript, this.hasOwnProperty("foo") would return “false” if > the property were inherited, “true” otherwise. But in Python, > hasattr(self, "foo") returns “True” regardless whether the “foo” > attribute of the calling instance has been assigned a value explicitly. > What is the Python equivalent of ECMAScript’s > Object.prototype.hasOwnProperty() method?
You could check "foo" in self.__dict__, but I don't know of any real-world situations where you need to. ChrisA -- https://mail.python.org/mailman/listinfo/python-list