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_dataclass=3A_Unterschied_zu_automatischer_Generierung_aus_dict?= Date: Fri, 13 May 2022 08:06:06 +0000 Lines: 30 Message-ID: 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 fBHKLAiA7fJ5d4W/IORi2w7eVQEm8K5ErclAbpyl/KHQ== Authentication-Results: mail.python.org; dkim=pass reason="2048-bit key; unprotected key" header.d=posteo.jp header.i=@posteo.jp header.b=HR5zxZ0p; dkim-adsp=pass; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.jp; s=2017; t=1652429167; bh=nkcfA6AyvJiwDNqibKtDuAAgcxHLAK9Fz5dTj9Eh25s=; h=Date:From:To:Subject:From; b=HR5zxZ0ptIyJ8t28jD/qMO074X02z8vPOsmygSNgLbUfsH4We9gLJx4ZhqNoGg1U2 bWhrFIIiV1UnbadH3vJRDai1Xs2NkVdOCVa3y94FVgOUqqcjHN/oVqUhcnzuxGRxUC xhTYF0+MC1bAiEd1sLOEzeG1XAL/7SARw+6wQUyyw8gd9V5GU6vGdX4YJkSqekFojs rkxSdLq6bA4WWCKb+DITWQLRo25MOvtViuXP9icgBA5+/L3Y9ZEe5P5gWfD3s0zhJd IVNTFT3VeRM1ge3mJ5HioFqEAy5OuxPQkKR8SwHcakvYe40YkP66PmGDFKSaQE1Rj6 +p/lmMqtof3kw== Mail-Reply-To: python-de@python.org Message-ID-Hash: XEYINZ3NWLVV56NEP5XJABHATLMANKUP X-Message-ID-Hash: XEYINZ3NWLVV56NEP5XJABHATLMANKUP 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:5818 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=20 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) Aber es gibt hier im Ergebnis einen Unterschied zu einer regul=C3=A4r=20 erzeugten dataclass. >>> X Regul=C3=A4r erzeugt >>> @dataclasses.dataclass =2E.. class X: =2E.. a: int =2E.. b: int =2E.. >>> X In einem Fall "types.X" und im anderen "__main__.X". Warum ist das so=20 und ist dieser Unterschied von Relevanz? SG Christian