Re: [Python-ideas] singledispatch for instance methods

2017-05-14 Thread Juancarlo Añez
On Sun, May 14, 2017 at 1:28 PM, Steven D’Aprano wrote: - contact Tim Mitchell and see if his offer of contributing the code > still stands; > FWIW, this is a Python implementation of a single-dispatch decorator for methods that I wrote from looking at the stdlib, and that I

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

2017-05-14 Thread Brendan Barnwell
On 2017-05-14 00:34, Chris Angelico wrote: On Sun, May 14, 2017 at 2:53 PM, Brendan Barnwell wrote: Attributes aren't just for passing things to other methods. They're for storing state. In your proposed system, how would an object mutate one of its own

Re: [Python-ideas] singledispatch for instance methods

2017-05-14 Thread Guido van Rossum
Thanks Steven. I think you've just concisely summarized the info in this section of the devguide: https://docs.python.org/devguide/stdlibchanges.html On Sun, May 14, 2017 at 10:28 AM, Steven D'Aprano wrote: > On Sun, May 14, 2017 at 05:10:53PM +, Bar Harel wrote: > > As

Re: [Python-ideas] singledispatch for instance methods

2017-05-14 Thread Steven D'Aprano
On Sun, May 14, 2017 at 05:10:53PM +, Bar Harel wrote: > As I said, sorry for that. > > It's just that I'm not entirely sure there's anything to implement here. > The implementation already exists. If it doesn't suffice I will help as > much as I can to make sure it works :-) I think you've

Re: [Python-ideas] singledispatch for instance methods

2017-05-14 Thread Steven D'Aprano
On Sun, May 14, 2017 at 04:37:32PM +, Bar Harel wrote: > I guess so. > > Sorry for that. > To be honest I'm not entirely sure of the entire procedure and if small > things need a PEP or not. I actually received the tip to bump from > core-mentorship, so now I'm rather confused. If you are

Re: [Python-ideas] singledispatch for instance methods

2017-05-14 Thread Bar Harel
As I said, sorry for that. It's just that I'm not entirely sure there's anything to implement here. The implementation already exists. If it doesn't suffice I will help as much as I can to make sure it works :-) On Sun, May 14, 2017, 7:49 PM Guido van Rossum wrote: > Maybe

Re: [Python-ideas] singledispatch for instance methods

2017-05-14 Thread Guido van Rossum
Maybe ask core membership if they meant you to literally just post just the word "bump" to the list (my guess is not). Also the last time I see that you received any advice was a long time ago and regarding to a different issue. For this idea there's no issue and no patch (and core devs aren't

Re: [Python-ideas] singledispatch for instance methods

2017-05-14 Thread Bar Harel
I guess so. Sorry for that. To be honest I'm not entirely sure of the entire procedure and if small things need a PEP or not. I actually received the tip to bump from core-mentorship, so now I'm rather confused. Anyway, shall I add it to the bug tracker as an enhancement? On Sun, May 14, 2017,

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

2017-05-14 Thread Guido van Rossum
On Sun, May 14, 2017 at 12:35 AM, Simon Ramstedt wrote: > What do you think are the odds of something like this actually making it > into the Python and if greater than 0 in which timeframe? > If you're asking for language or stdlib support or an official endorsement,

Re: [Python-ideas] singledispatch for instance methods

2017-05-14 Thread Guido van Rossum
PS: I didn't see a message from Lisa on the mailing list -- maybe she replied to you only? On Sun, May 14, 2017 at 9:25 AM, Guido van Rossum wrote: > How exactly do you think the process of adopting something into the stdlib > works? Just posting "bump" messages to the mailing

Re: [Python-ideas] singledispatch for instance methods

2017-05-14 Thread Guido van Rossum
How exactly do you think the process of adopting something into the stdlib works? Just posting "bump" messages to the mailing list doesn't really help, it just sounds rude.If you need help understanding how to add/improve a stdlib module, please ask a specific about that topic. On Sun, May 14,

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

2017-05-14 Thread Chris Angelico
On Sun, May 14, 2017 at 9:14 PM, Steven D'Aprano wrote: >> There are a couple of >> solutions to that, though. The easiest to implement would be to change the >> first line to `self = subclass(ParentClass())` where the subclass function >> looks at the next item in the call

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

2017-05-14 Thread Steven D'Aprano
On Sun, May 14, 2017 at 01:33:32PM +0200, Antoine Rozo wrote: > Also, how do you handle special methods for operators, such as __add__? Oh, that's a good point! I forgot about that. For implementation-dependent reasons, you couldn't use this proposed new syntax for dunder methods: def

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

2017-05-14 Thread Steven D'Aprano
On Sun, May 14, 2017 at 07:35:38AM +, Simon Ramstedt wrote: > Leaving the possible replacement for classes aside, do you have an opinion > specifically about the following? > > def obj.my_function(a, b): >... > > as syntactic sugar for > > def my_function(a, b): > ... > >

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

2017-05-14 Thread Antoine Rozo
Also, how do you handle special methods for operators, such as __add__? 2017-05-14 13:18 GMT+02:00 Steven D'Aprano : > On Sun, May 14, 2017 at 11:12:21AM +0400, Abdur-Rahmaan Janhangeer wrote: > > Whatever you all propose, > > > > coming from a java and c++ background, OOP

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

2017-05-14 Thread Steven D'Aprano
On Sun, May 14, 2017 at 11:12:21AM +0400, Abdur-Rahmaan Janhangeer wrote: > Whatever you all propose, > > coming from a java and c++ background, OOP in python is quite cumbersome. In what way it is cumbersome? > if you tell that i am not a python guy, then consider that current oop > style does

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

2017-05-14 Thread Simon Ramstedt
On Sunday, May 14, 2017 at 3:05:46 AM UTC-4, Steven D'Aprano wrote: > > On Sun, May 14, 2017 at 04:07:44AM +, Simon Ramstedt wrote: > > Hi, do you have an opinion on the following? > > Hi, and welcome, and of course we have an opinion! This is Python-Ideas, > we're very opinionated :-) >

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

2017-05-14 Thread Antoine Rozo
How do you call methods from superclass, like super in classic style ? 2017-05-14 9:45 GMT+02:00 Stephan Houben : > FWIW, Javascript itself is moving away from this syntax in favour of a > more Python-like syntax based on the 'class' keyword. This was introduced > in

Re: [Python-ideas] singledispatch for instance methods

2017-05-14 Thread Bar Harel
Bump On Wed, Jan 4, 2017, 8:01 PM Lisa Roach wrote: > +1 to this as well, I think this would be really useful in the stdlib. > > On Mon, Dec 26, 2016 at 5:40 AM, Bar Harel wrote: > >> Any updates with a singledispatch for methods? >> >> On Tue, Sep

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

2017-05-14 Thread Simon Ramstedt
Hi, thanks a lot for your feedback! On Sun, May 14, 2017, 00:54 Brendan Barnwell wrote: > On 2017-05-13 21:07, Simon Ramstedt wrote: > > Hi, do you have an opinion on the following? > > My general opinion is that imitating JavaScript is almost always a > bad >

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

2017-05-14 Thread Chris Angelico
On Sun, May 14, 2017 at 2:53 PM, Brendan Barnwell wrote: > Attributes aren't just for passing things to other methods. They're > for storing state. In your proposed system, how would an object mutate one > of its own attributes? It looks like "x" here is just

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

2017-05-14 Thread Abdur-Rahmaan Janhangeer
Whatever you all propose, coming from a java and c++ background, OOP in python is quite cumbersome. if you tell that i am not a python guy, then consider that current oop style does not reflect python's style of ease and simplicity is __init__ really a good syntax choice? Abdur-Rahmaan

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

2017-05-14 Thread Steven D'Aprano
On Sun, May 14, 2017 at 04:07:44AM +, Simon Ramstedt wrote: > Hi, do you have an opinion on the following? Hi, and welcome, and of course we have an opinion! This is Python-Ideas, we're very opinionated :-) > Wouldn't it be nice to define classes via a simple constructor function (as >

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

2017-05-14 Thread Bernardo Sulzbach
On 05/14/2017 01:53 AM, Brendan Barnwell wrote: On 2017-05-13 21:07, Simon Ramstedt wrote: Here are the pros and cons I could come up with for the proposed method: (+) Simpler and more explicit. I don't really see how that's simpler or more explicit. In one respect it's clearly less