Re: [Python-Dev] descriptor __set_name__ and dataclasses

2018-03-26 Thread Eric V. Smith
On 3/26/18 11:10 AM, Eric V. Smith wrote: On 3/26/18 11:08 AM, Nick Coghlan wrote: On 27 March 2018 at 00:40, Eric V. Smith wrote: Would it be feasible to define `Field.__set_name__`, and have that call `default.__set_name__` when the latter exists, and be a no-op otherwise? A clever idea!

Re: [Python-Dev] descriptor __set_name__ and dataclasses

2018-03-26 Thread Eric V. Smith
On 3/26/18 11:08 AM, Nick Coghlan wrote: On 27 March 2018 at 00:40, Eric V. Smith wrote: https://bugs.python.org/issue33141 points out an interesting issue with dataclasses and descriptors. Given this code: from dataclasses import * class D: """A descriptor class that knows its name."""

Re: [Python-Dev] descriptor __set_name__ and dataclasses

2018-03-26 Thread Nick Coghlan
On 27 March 2018 at 00:40, Eric V. Smith wrote: > https://bugs.python.org/issue33141 points out an interesting issue with > dataclasses and descriptors. > > Given this code: > > from dataclasses import * > > class D: > """A descriptor class that knows its name.""" > def __set_name__(self,

[Python-Dev] descriptor __set_name__ and dataclasses

2018-03-26 Thread Eric V. Smith
https://bugs.python.org/issue33141 points out an interesting issue with dataclasses and descriptors. Given this code: from dataclasses import * class D: """A descriptor class that knows its name.""" def __set_name__(self, owner, name): self.name = name def __get__(self, ins

Re: [Python-Dev] Replacing self.__dict__ in __init__

2018-03-26 Thread Tin Tvrtković
Thank you to everyone who participated (Kirill, Raymond, Nick, Naoki). I've decided there are too many caveats for this approach to be worthwhile and I'm giving up on it. Kind regards, Tin On Sat, Mar 24, 2018 at 3:18 PM Tin Tvrtković wrote: > Hi Python-dev, > > I'm one of the core attrs contri