Ethan Furman <et...@stoneleaf.us> added the comment:

This issue is not unique to Enum, and is not an Enum problem.

What is happening is that "test.py" has the `__name__` of `__main__` because it 
is being directly executed from the command line, but when `test2.py` imports 
it, it is being re-executed and everything inside is re-created -- so you end 
up with two copies of everything in that module.

You can also see this issue if you manage to import a module under two 
different names (usually by messing with `sys.path`).

To see it yourself, add a custom __str__ to A:

        def __str__(self):
            return "%s.%s.%s" % (
                    __name__,
                    self.__class__.
                   __qualname__, self._name_,
                   _)

Then your print() will show:

    __main__.A.a test.A.a

----------
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42953>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to