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 ethan.furman
Recipients Lcx994611818, ethan.furman
Date 2021-01-18.19:17:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1610997437.69.0.8760066278.issue42953@roundup.psfhosted.org>
In-reply-to
Content
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
History
Date User Action Args
2021-01-18 19:17:17ethan.furmansetrecipients: + ethan.furman, Lcx994611818
2021-01-18 19:17:17ethan.furmansetmessageid: <1610997437.69.0.8760066278.issue42953@roundup.psfhosted.org>
2021-01-18 19:17:17ethan.furmanlinkissue42953 messages
2021-01-18 19:17:17ethan.furmancreate