Message385219
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 |
|
Date |
User |
Action |
Args |
2021-01-18 19:17:17 | ethan.furman | set | recipients:
+ ethan.furman, Lcx994611818 |
2021-01-18 19:17:17 | ethan.furman | set | messageid: <1610997437.69.0.8760066278.issue42953@roundup.psfhosted.org> |
2021-01-18 19:17:17 | ethan.furman | link | issue42953 messages |
2021-01-18 19:17:17 | ethan.furman | create | |
|