Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: c.buhtz@posteo.jp Newsgroups: de.comp.lang.python Subject: =?utf-8?q?=5BPython-de=5D_Re=3A_dataclass=3A_Unterschied_zu_automatischer_Generierung?= Date: Fri, 13 May 2022 10:23:49 +0000 Lines: 46 Message-ID: <013a3cfd0c91a73055b920f9be9f45ad@posteo.de> References: Reply-To: python-de@python.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de V/1u8jk6iq2QJ6ZU7sR7oAxzN5gzfZpjl8PY+wmGEGVA== Authentication-Results: mail.python.org; dkim=pass reason="2048-bit key; unprotected key" header.d=posteo.jp header.i=@posteo.jp header.b=jgqC24YK; dkim-adsp=pass; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.jp; s=2017; t=1652437429; bh=QxAFXhSSvzlGrQb6HUsrBq/5BN/YMjFB26WxUbtC6FQ=; h=Date:From:To:Subject:From; b=jgqC24YKTrnWdIxQx1h6HVP8bloVqjEIBQHTjP0131B+2/pM1lgrAWRXXZPLi1m3R EMO7FK81n4PsV9pox2ahmjJA05b8+GvFsPjNVZYqWjJRvNbYDpwXfRN2SAylu6xWrt X4GZUBf9vdzkcV7naMKcLwWYNrzSxYjpUVe+p74mR/BTIhOHKsQbkGu/pGCoGfQD0w s8dJ8+3gE0yInc+9bNzWdMvUfcLNsn5ir4Bv/Mwcu6Zm6xSgUdwoji9v21GmG2JQi6 9A2t+BETxqyxISFyh3V50acF8GlC4el4nyrsqxR2d23rEwv93zw1xg8pIlAbu+b/9y W4ZS2T+cFHdUg== Mail-Reply-To: python-de@python.org In-Reply-To: Message-ID-Hash: ZCGVW3MLWFNTOLL4FB67YK4U6GSFMR6Q X-Message-ID-Hash: ZCGVW3MLWFNTOLL4FB67YK4U6GSFMR6Q X-MailFrom: c.buhtz@posteo.jp X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-python-de.python.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.6b1 Precedence: list List-Id: Die Deutsche Python Mailingliste Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Xref: csiph.com de.comp.lang.python:5819 Eine Konsequenz scheint zu sein, dass ich eine automatisch erzeugte=20 dataclass nicht pickeln kann. Ich bekomme den Fehler=20 "_pickle.PicklingError: Can't pickle : attribute lookup=20 X on types failed" Wenn ich aber den Modulnamen =C3=A4ndere x.__module__ =3D '__main__' geht es auch mit Pickle. Am 13.05.2022 10:06 schrieb c.buhtz@posteo.jp: > Hallo, >=20 > meine Frage bezieht sich auf dieses StackOverflow-Posting: > https://stackoverflow.com/q/72217470/4865723 >=20 > Dort geht es darum, wie man aus den Keys eines dict automatisch eine > dataclass erzeugen k=C3=B6nnte. Erst einmal erscheint es einfach: >>>> import dataclasses >>>> d =3D {'a': 3, 'b': 7} >>>> X =3D dataclasses.make_dataclass('X', d) >=20 > Aber es gibt hier im Ergebnis einen Unterschied zu einer regul=C3=A4r > erzeugten dataclass. >>>> X > >=20 > Regul=C3=A4r erzeugt >>>> @dataclasses.dataclass > ... class X: > ... a: int > ... b: int > ... >>>> X > >=20 > In einem Fall "types.X" und im anderen "__main__.X". Warum ist das so > und ist dieser Unterschied von Relevanz? >=20 > SG > Christian > _______________________________________________ > python-de Mailingliste -- python-de@python.org > Zur Abmeldung von dieser Mailingliste senden Sie eine Nachricht an > python-de-leave@python.org > https://mail.python.org/mailman3/lists/python-de.python.org/ > Mitgliedsadresse: c.buhtz@posteo.jp