Re: [Python-ideas] JavaScript-Style Object Creation in Python (using a constructor function instead of a class to create objects)

2017-05-16 Thread Ivan Levkivskyi
On 15 May 2017 at 18:22, Guido van Rossum wrote: > I expect that we will need someone with a really good sensibility for > Pythonic language/API design to lead the PEP writing. > I probably don't have good sensibility for Pythonic API design yet (and I am more focused on PEP 544) so I cannot lea

Re: [Python-ideas] JavaScript-Style Object Creation in Python (using a constructor function instead of a class to create objects)

2017-05-16 Thread Guido van Rossum
I could also try this myself in my spare time at PyCon (surprisingly, I have some!). It sounds kind of interesting. However I've never used the 'attrs' package... On Tue, May 16, 2017 at 7:52 AM, Ivan Levkivskyi wrote: > On 15 May 2017 at 18:22, Guido van Rossum wrote: > >> I expect that we wil

Re: [Python-ideas] JavaScript-Style Object Creation in Python (using a constructor function instead of a class to create objects)

2017-05-16 Thread Eric V. Smith
I wouldn't mind discussing it at PyCon. I'm just starting a project to switch to attrs, and I'm reasonably familiar with it. -- Eric. > On May 16, 2017, at 10:53 AM, Guido van Rossum wrote: > > I could also try this myself in my spare time at PyCon (surprisingly, I have > some!). It sounds ki

Re: [Python-ideas] JavaScript-Style Object Creation in Python (using a constructor function instead of a class to create objects)

2017-05-16 Thread Chris Angelico
On Wed, May 17, 2017 at 12:53 AM, Guido van Rossum wrote: > I could also try this myself in my spare time at PyCon (surprisingly, I have > some!). It sounds kind of interesting. However I've never used the 'attrs' > package... Me neither, so I'm not really an ideal person to head this up. Is ther

Re: [Python-ideas] JavaScript-Style Object Creation in Python (using a constructor function instead of a class to create objects)

2017-05-16 Thread Guido van Rossum
Maybe Lukasz is interested? On May 16, 2017 8:00 AM, "Chris Angelico" wrote: > On Wed, May 17, 2017 at 12:53 AM, Guido van Rossum > wrote: > > I could also try this myself in my spare time at PyCon (surprisingly, I > have > > some!). It sounds kind of interesting. However I've never used the >

Re: [Python-ideas] Python-ideas Digest, Vol 126, Issue 35

2017-05-16 Thread Tin Tvrtković
I have it on good authority both Hynek (the author of attrs) and Glyph will be attending PyCon. I think it'd be a shame if they weren't involved with this effort somehow. > Message: 2 > Date: Tue, 16 May 2017 07:53:50 -0700 > From: Guido van Rossum > To: Ivan Levkivskyi > Cc: ? , "python-id

Re: [Python-ideas] Python-ideas Digest, Vol 126, Issue 35

2017-05-16 Thread Brett Cannon
I'm sure at least Hynek will be told about this so he can provide input based on his experience (but I also know my rough approximation of this idea somewhat horrified him so I don't know he supportive he will be either :) . On Tue, 16 May 2017 at 09:58 Tin Tvrtković wrote: > I have it on good a

Re: [Python-ideas] JavaScript-Style Object Creation in Python (using a constructor function instead of a class to create objects)

2017-05-16 Thread Brett Cannon
Maybe we can bring this up as a lightning talk at the language summit to see who in the room has the appropriate background knowledge? And obviously someone can talk to Hynek to see if he wants to provide input based on community feedback for attrs and lessons learned. On Tue, 16 May 2017 at 08:11

Re: [Python-ideas] JavaScript-Style Object Creation in Python (using a constructor function instead of a class to create objects)

2017-05-16 Thread Stephan Houben
Hi all, Thanks to this thread I learned about the "attrs" library. I am a heavy namedtuple (ab)user but I think I will be using attrs going forward. If something like attrs would made it in the standard library it would be awesome. Thanks, Stephan 2017-05-16 20:08 GMT+02:00 Brett Cannon : > Ma

Re: [Python-ideas] JavaScript-Style Object Creation in Python (using a constructor function instead of a class to create objects)

2017-05-16 Thread Guido van Rossum
Stephen, What features of attrs specifically solve your use cases? --Guido On Tue, May 16, 2017 at 12:18 PM, Stephan Houben wrote: > Hi all, > > Thanks to this thread I learned about the "attrs" library. I am a > heavy namedtuple (ab)user but I think > I will be using attrs going forward. > >

[Python-ideas] PEP 526: why ClassVar instead of ClassAttr?

2017-05-16 Thread Steven D'Aprano
Since PEP 526 is already provisionally accepted, it may be too late to bring this up, but I have a question and suggestion about the name ClassVar. I've read the PEP but didn't see an answer or rejection to this. https://www.python.org/dev/peps/pep-0526/ Why choose ClassVar over ClassAttr when

Re: [Python-ideas] PEP 526: why ClassVar instead of ClassAttr?

2017-05-16 Thread Guido van Rossum
It's "class variable" because we (at least I) also routinely use "instance variable". On Tue, May 16, 2017 at 4:23 PM, Steven D'Aprano wrote: > Since PEP 526 is already provisionally accepted, it may be too late to > bring this up, but I have a question and suggestion about the name > ClassVar.

Re: [Python-ideas] PEP 526: why ClassVar instead of ClassAttr?

2017-05-16 Thread Juancarlo Añez
On Tue, May 16, 2017 at 10:10 PM, Guido van Rossum wrote: > It's "class variable" because we (at least I) also routinely use "instance > variable". It is `getattr()`, `setattr()`, and a very long etc. in Python. I agree with the OP that a sudden talk about "vars" is confusing, more so when Py

Re: [Python-ideas] JavaScript-Style Object Creation in Python (using a constructor function instead of a class to create objects)

2017-05-16 Thread Juancarlo Añez
On Tue, May 16, 2017 at 5:04 PM, Guido van Rossum wrote: What features of attrs specifically solve your use cases? > (not Stephen) I hadn’t thought about this use case: In [1]: class C(): ...: x = 1 ...: ...: def __init__(self, x=None): ...: if x is not None: ...:

Re: [Python-ideas] PEP 526: why ClassVar instead of ClassAttr?

2017-05-16 Thread Guido van Rossum
There was another reason too. Many things are "class attributes" e.g. methods, descriptors. But only specific things are class *variables*. Trust me, we debated this when the PEP was drafted. ClassVar is better than ClassAttr. On Tue, May 16, 2017 at 7:54 PM, Juancarlo Añez wrote: > > On Tue, Ma

Re: [Python-ideas] JavaScript-Style Object Creation in Python (using a constructor function instead of a class to create objects)

2017-05-16 Thread Guido van Rossum
On Tue, May 16, 2017 at 8:14 PM, Juancarlo Añez wrote: > What I like about attrs is: > >- The class level declaration of instance attributes >- That the reasonable *init*, *repr*, and *eq* are generated > > OK, the former should be doable using PEP 526 (the type is stored in __annotations

Re: [Python-ideas] JavaScript-Style Object Creation in Python (using a constructor function instead of a class to create objects)

2017-05-16 Thread Stephan Houben
Hi Guido, As mentioned I am a heavy user of namedtuple, I use it everywhere where constructor arguments are equal to instance variables. Which is quite often, at least in my programming style (possibly under the influence of ML's "datatype" and Scala's "case class"-es.) Compared to namedtuple, I