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

Sven R. Kunze srkunze at mail.de
Thu May 18 17:26:30 EDT 2017


On 17.05.2017 23:29, Ivan Levkivskyi wrote:
> On 17 May 2017 at 20:09, Sven R. Kunze <srkunze at mail.de 
> <mailto:srkunze at mail.de>> wrote:
>
>     class Foo(dictlike, tuplelike, simpleobject):
>         attribute1: User
>         attribute2: Blog
>         attribute3: list
>
>          def __my_dunder__(self):
>             ...
>
>
> As I understand this is more or less what is proposed,

Are you sure? Could you point me to the relevant messages where mixins 
are mentioned as a key part of the proposal? All I could find are 
message using the @decorator syntaxes.

We've been working with mixins successfully for years now and I can tell 
you that it's "just" a clever way of refactoring existing code in order 
to make it more accessible to other modules *based on use-cases*.


So, the best person to tell what pieces to factor out would be Stephan 
using his 4-point list.
And of course other people using NamedTuple but frequently refactoring 
to "attr" or own class because NamedTuple just is too much (defines too 
much implicitly).


Another benefit is that NamedTuple itself would become a mere set of 
base class and mixins.


> the idea is to write it into a PEP and consider API/corner 
> cases/implementation/etc.

Who's writing it?


Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170518/8816a669/attachment.html>


More information about the Python-ideas mailing list