<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Sep 13, 2017 at 3:01 PM, Ivan Levkivskyi <span dir="ltr"><<a href="mailto:levkivskyi@gmail.com" target="_blank">levkivskyi@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>@Guido<span class=""><br>> One would have to introduce some kind of convention<br>> where you can write properties with a leading _</span><div><br>One doesn't even need the @property decorator in this case.</div><div>For example:</div><span class=""><div><br></div><div><div>def __getattr__(name):</div><div>    g = globals()</div><div>    name = '_' + name</div><div>    if name in g:</div><div>        return g[name]()</div>    raise AttributeError(...)</div><div><br></div></span><div>def _attr():</div><div>    "do something"</div><div>    return actual_object</div><br></div>One can even write a decorator that would change the name automatically<br></div>(but this will require a call at the end of module to unbind original names).</div><div>The space for play is infinite. The question is what exactly is needed.</div><div>I would say that already basic customisation (like __getattr__) will be enough.</div><div>IIUC, this will be actually a bit faster than setting __class__ since only "customized"</div><div>attributes will be affected.</div></div></blockquote><div><br></div><div>That last sentence is a key observation. Do we even know whether there are (non-toy) things that you can do *in principle* with __class__ assignment but which are too slow *in practice* to bother? And if yes, is __getattr__ fast enough? @property?</div><div><br></div><div>IMO we're still looking for applications.<br></div></div><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div></div>