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

2017-05-13 Thread Simon Ramstedt
Hi, do you have an opinion on the following? Wouldn't it be nice to define classes via a simple constructor function (as below) instead of a conventional class definition? *conventional*: class MyClass(ParentClass): def __init__(x): self._x = x def my_method(y): z

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

2017-05-13 Thread Brendan Barnwell
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 idea. :-) Wouldn't it be nice to define classes via a simple constructor function (as below) instead of a conventional class defin

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

2017-05-13 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 e