On Tue, 26 Dec 2017 at 21:00 Ned Batchelder <n...@nedbatchelder.com> wrote:

> On 12/26/17 1:49 PM, Chris Barker wrote:
>
> On Sat, Dec 23, 2017 at 5:54 PM, Nick Coghlan <ncogh...@gmail.com> wrote:
>
>>
>> I still wonder about the "fields *must* be annotated" constraint though.
>> I can understand a constraint that the style be *consistent* (i.e. all
>> fields as annotations, or all fields as field instances), since that's
>> needed to determine the field order, but I don't see the problem with the
>> "no annotations" style otherwise.
>>
>
> IIUC, without annotations, there is no way to set a field with no default.
>
> And supporting both approaches violates "only one way to do it" in, I
> think, a confusing manner -- particularly if you can't mix and match them.
>
> Also, could does using class attributes without annotations make a mess
> when subclassing? -- no I haven't thought that out yet.
>
>
>
> I have not been following the design of dataclasses, and maybe I'm
> misunderstanding the state of the work.  My impression is that attrs was a
> thing, and lots of people loved it, so we wanted something like it in the
> stdlib.
>

Yes.


>   Data Classes is that thing, but it is a new thing being designed from
> scratch.  There are still big questions about how it should work, but it is
> already a part of 3.7.
>

I wouldn't characterize it as "big questions". For some people there's a
question as to how to make them work without type hints, but otherwise how
they function is settled.


>
> Often when people propose new things, we say, "Put it on PyPI first, and
> let's see how people like it."  Why isn't that the path for Data Classes?
> Why are they already part of 3.7 when we have no practical experience with
> them?  Wouldn't it be better to let the design mature with real
> experience?  Especially since some of the questions being asked are about
> how it interrelates with another large new feature with little practical
> use yet (typing)?
>

The short answer: "Guido said so". :)

The long answer (based on my understanding, which could be wrong :) : Guido
liked the idea of an attrs-like thing in the stdlib, but not attrs itself
as Guido was after a different API. Eric V. Smith volunteered to work on a
solution, and so Guido, Hynek, and Eric got together and discussed things
at PyCon US. A design was hashed out, Eric went away and implemented it,
and that led to the current solution. The only thing left is some people
don't like type hints and so they don't want a stdlib module that requires
them to function (there's no issue with how they relate *to* type hints,
just how to make dataclasses work *without* type hints). So right now we
are trying to decide what should represent the "don't care" type hint.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to