<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sun, Sep 10, 2017 at 9:36 AM, Eric V. Smith <span dir="ltr"><<a href="mailto:eric@trueblade.com" target="_blank">eric@trueblade.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 9/10/2017 10:00 AM, Michel Desmoulin wrote:</span><span class=""><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
- any chance it becomes a built in later ? When classes have been<br>
improved in Python 2, the object built-in was added. Imagine if we had<br>
had to import it every time... Or maybe just plug it to object like<br>
@object.dataclass.<br>
</blockquote>
<br></span>
Because of the choice of using module-level functions so as to not introduce conflicts in the object's namespace, it would be difficult to make this a builtin.<br></blockquote><div><br></div><div>The temptation to make everything a builtin should be resisted.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Although now that I think about it, maybe what are currently module-level functions should instead be methods on the "dataclass" decorator itself:<br>
<br>
@dataclass<br>
class C:<br>
  i: int = dataclass.field(default=1, init=False)<br>
  j: str<br>
<br>
c = C('hello')<br>
<br>
dataclass.asdict(c)<br>
{'i': 1, 'j': 'hello'}<br>
<br>
Then, "dataclass" would be the only name the module exports, making it easier to someday be a builtin. I'm not sure it's important enough for this to be a builtin, but this would make it easier. Thoughts? I'm usually not a fan of having attributes on a function: it's why itertools.chain.from_iterable(<wbr>) is hard to find.<span class="HOEnZb"><font color="#888888"></font></span><br></blockquote></div></div><div class="gmail_extra"><br></div><div class="gmail_extra">Let's not do that.</div><div class="gmail_extra"><br></div><div class="gmail_extra">It would be better to design the module so that people can write `from dataclasses import *` and they will only get things that are clearly part of dataclasses (I guess dataclass, field, asdict, and a few more like that). That way people who really want this to look like a builtin can just violate PEP 8.<br clear="all"></div><div class="gmail_extra"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div></div>