Backport python 3.7 dataclass
See original GitHub issueA new dataclass
decorator was recently accepted into python 3.7 (https://www.python.org/dev/peps/pep-0557/).
The implementation seems similar to coconut’s implementation of the data
type (subclassing the namedtuple) but they differ in terms of their syntax. I was just wondering whether coconut
would keep the current syntax (for backward compatibility) or would it be changing to the new syntax (to avoid feature duplication). I just asked this question because I’m curious.
Issue Analytics
- State:
- Created 6 years ago
- Comments:15 (8 by maintainers)
Top Results From Across the Web
dataclasses - PyPI
This is an implementation of PEP 557, Data Classes. It is a backport for Python 3.6. Because dataclasses will be included in Python...
Read more >Data Classes in Python 3.7+ (Guide)
If you do not yet have Python 3.7, there is also a data classes backport for Python 3.6. And now, go forth and...
Read more >Backport slots=True and kw_only=True from Python 3.10 #166
The problem is that "import dataclasses" in 3.7 will use the stdlib version of dataclasses, which does not have kw_only. This could be...
Read more >dataclasses — Data Classes — Python 3.11.1 documentation
Source code: Lib/dataclasses.py This module provides a decorator and functions for automatically adding generated special method s ... New in version 3.7.
Read more >How to use Python dataclasses - InfoWorld
Dataclasses, introduced in Python 3.7 (and backported to Python 3.6), provide a handy way to make classes less verbose. Many of the common ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For older versions of Python, we can get same functionality of
dataclasses
via attrs, as this says, it support PyPi, Python 2.7, 3.4+.It supports
__slot__
,__eq__
and lots of other features.
I’m wondering if it is allowed to add this package as dependency of coconut?
If it is allowed, I’m wondering how to learn about the compiling process of
data
. I’ve founddata_handle
in L1202 ofcompiler/compiler.py
, and it seems that for basicdata
support, only block after L1331elif saw_defaults:
should be modified, but there I’m confused of matchingsimple
,docstring
, e.t.c instmts
. How to learn this block of code? I can’t add break point to compiler, and addingprint
statement seems not work.On the other hand, May data support annotations from [PEP 526]? Thus like
The dataclass decorator accepts a “freeze” argument which makes the instances read-only (well, as read-only as anything gets in Python).
On Fri, Dec 8, 2017 at 3:27 PM, Dileep Kishore notifications@github.com wrote:
– Benji York