This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author steven.daprano
Recipients AluminumPirate, steven.daprano
Date 2021-03-16.17:45:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1615916704.13.0.553853846352.issue43519@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2021-03-16 17:45:04steven.dapranosetrecipients: + steven.daprano, AluminumPirate
2021-03-16 17:45:04steven.dapranosetmessageid: <1615916704.13.0.553853846352.issue43519@roundup.psfhosted.org>
2021-03-16 17:45:04steven.dapranolinkissue43519 messages
2021-03-16 17:45:03steven.dapranocreate