<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Nov 30, 2015 at 6:14 PM, Chris Angelico <span dir="ltr"><<a href="mailto:rosuav@gmail.com" target="_blank">rosuav@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div class="h5"><span style="color:rgb(34,34,34)">def call(func):</span><br></div></div>
def inner(cls):<br>
return func(**{k:v for k,v in cls.__dict__.items() if not<br>
k.startswith('_')})<br>
return inner<br>
<span class=""><br>
class Foo:<br>
def __init__(self):<br>
self._x = 42<br>
</span> @call(property)<br>
class x:<br>
<span class=""> def fget(self):<br>
return self._x<br>
def fset(self, value):<br>
self._x = value<br>
def fdel(self):<br>
del self._x<br></span></blockquote><div><br></div><div>I think this looks perfectly nice, actually. I was just trying to work out almost the same thing but using a `def x()` rather than `class f` as the nesting construct. I think Chris' is better though. I think I might want to define something like:</div><div><br></div></div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_extra"><div class="gmail_quote"><div>make_property = call(property)</div></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_extra"><div class="gmail_quote"><span class="">class Foo:<br> def __init__(self):<br> self._x = 42<br></span> @make_property<br> class x:<br><span class=""> def fget(self):<br> return self._x<br> def fset(self, value):<br> self._x = value<br> def fdel(self):<br> del self._x</span></div></div></blockquote><div class="gmail_extra"><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Keeping medicines from the bloodstreams of the sick; food <br>from the bellies of the hungry; books from the hands of the <br>uneducated; technology from the underdeveloped; and putting <br>advocates of freedom in prisons. Intellectual property is<br>to the 21st century what the slave trade was to the 16th.<br></div>
</div></div>