Re: [Python-Dev] pep-0557 dataclasses top level module vs part of collections?

2017-12-21 Thread Raymond Hettinger
> On Dec 21, 2017, at 3:21 PM, Gregory P. Smith wrote: > > It seems a suggested use is "from dataclasses import dataclass" > > But people are already familiar with "from collections import namedtuple" > which suggests to me that "from collections import dataclass" would be a

Re: [Python-Dev] f-strings

2017-12-21 Thread Stephen J. Turnbull
Eric Fahlgren writes: > On Tue, Dec 19, 2017 at 8:47 AM, Stephen J. Turnbull < > turnbull.stephen...@u.tsukuba.ac.jp> wrote: > > > If I were Bach, I'd compose a more-itertools-like module to be named > > Variations_on_the_F_String. :-) > > > > Would that be P.D.Q. Bach to whom you are

Re: [Python-Dev] Guarantee ordered dict literals in v3.7?

2017-12-21 Thread Stephen J. Turnbull
Chris Barker writes: > Nathaniel Smith has pointed out that eval(pprint(a_dict)) is > supposed to return the same dict -- so documented behavior may > already be broken. Sure, but that's because we put shoes on a snake. Why anybody expects no impediment to slithering, I don't know! I

Re: [Python-Dev] pep-0557 dataclasses top level module vs part of collections?

2017-12-21 Thread Eric Snow
On Thu, Dec 21, 2017 at 4:21 PM, Gregory P. Smith wrote: > It seems a suggested use is "from dataclasses import dataclass" > > But people are already familiar with "from collections import namedtuple" > which suggests to me that "from collections import dataclass" would be a >

Re: [Python-Dev] is typing optional in dataclasses?

2017-12-21 Thread Eric V. Smith
On 12/21/2017 7:55 PM, MRAB wrote: On 2017-12-22 00:19, Gregory P. Smith wrote: (subject for this sub-thread updated) On Thu, Dec 21, 2017 at 4:08 PM Chris Barker > wrote:     On Thu, Dec 21, 2017 at 3:36 PM, Gregory P. Smith

Re: [Python-Dev] is typing optional in dataclasses?

2017-12-21 Thread MRAB
On 2017-12-22 00:19, Gregory P. Smith wrote: (subject for this sub-thread updated) On Thu, Dec 21, 2017 at 4:08 PM Chris Barker > wrote: On Thu, Dec 21, 2017 at 3:36 PM, Gregory P. Smith >

Re: [Python-Dev] is typing optional in dataclasses?

2017-12-21 Thread Gregory P. Smith
(subject for this sub-thread updated) On Thu, Dec 21, 2017 at 4:08 PM Chris Barker wrote: > On Thu, Dec 21, 2017 at 3:36 PM, Gregory P. Smith wrote: > > >> But we already have ... which does - so I'd suggest that for people who >> are averse to

Re: [Python-Dev] Is static typing still optional?

2017-12-21 Thread Chris Barker
On Thu, Dec 21, 2017 at 3:36 PM, Gregory P. Smith wrote: > But we already have ... which does - so I'd suggest that for people who > are averse to importing anything from typing and using the also quite > readable Any. (ie: document this as the expected practice with both

Re: [Python-Dev] Is static typing still optional?

2017-12-21 Thread Gregory P. Smith
On Thu, Dec 21, 2017 at 3:10 PM MRAB wrote: > On 2017-12-21 22:45, Chris Barker wrote: > > On Thu, Dec 21, 2017 at 11:55 AM, Terry Reedy > > wrote: > > > > I think the understanding problem with this feature arises from

[Python-Dev] pep-0557 dataclasses top level module vs part of collections?

2017-12-21 Thread Gregory P. Smith
It seems a suggested use is "from dataclasses import dataclass" But people are already familiar with "from collections import namedtuple" which suggests to me that "from collections import dataclass" would be a more natural sounding API addition. But the dataclasses module has additional APIs

Re: [Python-Dev] Is static typing still optional?

2017-12-21 Thread MRAB
On 2017-12-21 22:45, Chris Barker wrote: On Thu, Dec 21, 2017 at 11:55 AM, Terry Reedy > wrote: I think the understanding problem with this feature arises from two factors: using annotations to define possibly un-initialized slots is

Re: [Python-Dev] Is static typing still optional?

2017-12-21 Thread Chris Barker
On Thu, Dec 21, 2017 at 11:55 AM, Terry Reedy wrote: I think the understanding problem with this feature arises from two > factors: using annotations to define possibly un-initialized slots is > non-obvious; a new use of annotations for something other than static > typing is a

Re: [Python-Dev] Is static typing still optional?

2017-12-21 Thread Steve Holden
On Thu, Dec 21, 2017 at 7:55 PM, Terry Reedy wrote: > On 12/21/2017 9:23 AM, Eric V. Smith wrote: > >> >> >> On 12/21/17 6:25 AM, Sven R. Kunze wrote: >> >>> On 21.12.2017 11:22, Terry Reedy wrote: >>> @dataclass >> class C: >> a: int # integer field with

Re: [Python-Dev] Is static typing still optional?

2017-12-21 Thread Terry Reedy
On 12/21/2017 9:23 AM, Eric V. Smith wrote: On 12/21/17 6:25 AM, Sven R. Kunze wrote: On 21.12.2017 11:22, Terry Reedy wrote: @dataclass class C: a: int # integer field with no default b: float = 0.0 # float field with a default And the types will be recognized by type checkers

Re: [Python-Dev] Is static typing still optional?

2017-12-21 Thread Eric V. Smith
On 12/21/17 6:25 AM, Sven R. Kunze wrote: On 21.12.2017 11:22, Terry Reedy wrote: @dataclass class C: a: int # integer field with no default b: float = 0.0 # float field with a default And the types will be recognized by type checkers such as mypy. And I think the non-typed

Re: [Python-Dev] Is static typing still optional?

2017-12-21 Thread Ivan Levkivskyi
On 21 December 2017 at 11:22, Terry Reedy wrote: > On 12/21/2017 4:22 AM, Eric V. Smith wrote: > >> On 12/21/2017 1:46 AM, Chris Barker wrote: >> > > I suggest that it be clear in the docs, and ideally in the PEP, that the >>> dataclass decorator is using the *annotation"

Re: [Python-Dev] Is static typing still optional?

2017-12-21 Thread Sven R. Kunze
On 21.12.2017 11:22, Terry Reedy wrote: @dataclass class C: a: int # integer field with no default b: float = 0.0 # float field with a default And the types will be recognized by type checkers such as mypy. And I think the non-typed examples should go first in the docs. I still

Re: [Python-Dev] Is static typing still optional?

2017-12-21 Thread Terry Reedy
On 12/21/2017 4:22 AM, Eric V. Smith wrote: On 12/21/2017 1:46 AM, Chris Barker wrote: I suggest that it be clear in the docs, and ideally in the PEP, that the dataclass decorator is using the *annotation" syntax, and that the the only relevant part it uses is that an annotation exists, but

Re: [Python-Dev] Is static typing still optional?

2017-12-21 Thread Eric V. Smith
On 12/21/2017 1:46 AM, Chris Barker wrote: On Wed, Dec 20, 2017 at 5:29 PM, Eric V. Smith > wrote: There is definitely a passive bias towards using types with dataclasses in that the Eric (the author) doesn't appear to want an example