On Thu, Jun 6, 2019 at 4:15 AM Christoph Groth <[email protected]>
wrote:

> Yonatan Zunger wrote:
>
> > I had a similar recent need, with a bit more on top of it, and solved it
> > with this slightly insane library. (Alas, I haven't figured out a good
> way
> > to make it act as a true subtype of UnderlyingType yet)
> >
> > (...)
>
> To me, your trick seems to address a different problem.  You want
> context variables to be transparent and behave themselves as the data
> that they hold (in C++ terms: you want reference semantics instead of
> pointer semantics).
>
> This trick might be necessary at some times (like your example of
> replacing sys.stdout with a context var), but I consider it dangerous
> for general usage.
>

Oh, absolutely. There's a reason I wasn't proposing that this be added to
any standard
library. :)

That said, it (and other things) have made me think that it would be very
nice to have a better
way of expressing duck-type inheritance in the typing system that doesn't
rely on the superclass
declaring itself in particular ways, but that's an entirely separate issue
and one I haven't thought
through in any detail yet.
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/5NMIXO5AMOEG4SGW2ZSRCFTHPWMKOT4H/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to