Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > de.comp.lang.python > #5818
| 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 | [Python-de] dataclass: Unterschied zu automatischer Generierung aus dict |
| Date | Fri, 13 May 2022 08:06:06 +0000 |
| Lines | 30 |
| Message-ID | <f2138ea335d55c76b5e2433fc8710713@posteo.de> (permalink) |
| 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 <python-de.python.org> |
| Archived-At | <https://mail.python.org/archives/list/python-de@python.org/message/XEYINZ3NWLVV56NEP5XJABHATLMANKUP/> |
| List-Archive | <https://mail.python.org/archives/list/python-de@python.org/> |
| List-Help | <mailto:python-de-request@python.org?subject=help> |
| List-Owner | <mailto:python-de-owner@python.org> |
| List-Post | <mailto:python-de@python.org> |
| List-Subscribe | <mailto:python-de-join@python.org> |
| List-Unsubscribe | <mailto:python-de-leave@python.org> |
| Xref | csiph.com de.comp.lang.python:5818 |
Show key headers only | View raw
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
Back to de.comp.lang.python | Previous | Next — Next in thread | Find similar
[Python-de] dataclass: Unterschied zu automatischer Generierung aus dict c.buhtz@posteo.jp - 2022-05-13 08:06 +0000
[Python-de] Re: dataclass: Unterschied zu automatischer Generierung c.buhtz@posteo.jp - 2022-05-13 10:23 +0000
[Python-de] Re: dataclass: Unterschied zu automatischer Stefan Behnel <python-de@behnel.de> - 2022-05-13 18:03 +0200
csiph-web