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

Bernardo Sulzbach mafagafogigante at gmail.com
Sun May 14 02:01:25 EDT 2017

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 explicit, as the "self" is implicit.

I cannot imagine that the average Python programmer would consider this 
to be simpler or more explicit than the current way of creating objects.

Some purists may argue in your favor, saying that by not having the _x 
attribute your code is more robust as you cannot accidentally change _x
later and end up modifying how a method works.

I don't think this is worse. However, I do think it is unnecessary.

More information about the Python-ideas mailing list