Steven D'Aprano <steve+pyt...@pearwood.info> added the comment:
This is not a bug, it is working as intended. Python does not really support "private" attributes, except by convention. Names that begin with a single leading underscore are no different than any other name to the interpreter, but the reader is expected to not touch it. Double-underscore names are no different, except that they have their names mangled so that subclasses can have their own version of the attribute that doesn't clash with that of the parent class. Most people find that the double-underscore attributes are not worth the trouble. However you may like to read this: https://www.python.org/dev/peps/pep-0008/#id49 By the way, attributes and variables in Python don't have fixed memory addresses. Whatever you did to make you think that: "Both are located on a different location in memory." you have misinterpreted what you are seeing. There is no language feature to get the memory address of any object or variable in Python, except perhaps as an accident of implementation. And some interpreters include compacting garbage collectors that can move objects around memory. ---------- nosy: +steven.daprano resolution: -> not a bug stage: -> resolved status: open -> closed _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue43519> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com