Eric V. Smith added the comment:
You're importing main.py twice. The first is when you run "python main.py",
where it has the module name '__main__'. The second time is in codegen.py,
where it has the name 'main'. You create the AtomX instance as __main__.AtomX,
but the isinstance check is a
Oleg Baskakov added the comment:
Sorry, I forgot to add if __name__ line:
```
import codegen
from dataclasses import dataclass
@dataclass
class AtomX:
my_symbol: str
quantity: str = ""
if __name__ == "__main__":
codegen.inheritance_map(AtomX("qwerty"))
```
So the output:
```
Tr
Eric V. Smith added the comment:
I get a circular import error:
Traceback (most recent call last):
File "main.py", line 1, in
import codegen
File "/cygdrive/c/home/eric/codegen.py", line 1, in
from main import AtomX
File "/cygdrive/c/home/eric/main.py", line 9, in
codegen.
New submission from Oleg Baskakov :
Hey I was trying to import dataclasses from another file and somehow isinstance
doesn't work anymore:
main.py:
```
import codegen
from dataclasses import dataclass
@dataclass
class AtomX:
my_symbol: str
quantity: str = ""
codegen.inheritance_map(Ato