[Python-de] dataclass: Unterschied zu automatischer Generierung aus dict

[email protected]
Newsgroups gmane.comp.python.general.german
Message-ID <[email protected]>
Hallo,

meine Frage bezieht sich auf dieses StackOverflow-Posting:
https://stackoverflow.com/q/72217470/4865723

Dort geht es darum, wie man aus den Keys eines dict automatisch eine 
dataclass erzeugen könnte. Erst einmal erscheint es einfach:
>>> import dataclasses
>>> d = {'a': 3, 'b': 7}
>>> X = dataclasses.make_dataclass('X', d)

Aber es gibt hier im Ergebnis einen Unterschied zu einer regulär 
erzeugten dataclass.
>>> X
<class 'types.X'>

Regulär erzeugt
>>> @dataclasses.dataclass
... class X:
...     a: int
...     b: int
...
>>> X
<class '__main__.X'>

In einem Fall "types.X" und im anderen "__main__.X". Warum ist das so 
und ist dieser Unterschied von Relevanz?

SG
Christian
_______________________________________________
python-de Mailingliste -- [email protected]
Zur Abmeldung von dieser Mailingliste senden Sie eine Nachricht an [email protected]
https://mail.python.org/mailman3/lists/python-de.python.org/
Mitgliedsadresse: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.