<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">2014-06-03 22:37 GMT+02:00 Piergiuliano Bossi <span dir="ltr"><<a href="mailto:pgbossi@gmail.com" target="_blank">pgbossi@gmail.com</a>></span>:<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">Questa non puo' funzionare, invoco func anche con un Dad().</blockquote>
</div><br>ahahah ma l'hai provata?</div><div class="gmail_extra">sarà una delle magie di python?</div><div class="gmail_extra"><br><div><div class="gmail_extra">In [6]: %doctest_mode</div><div class="gmail_extra">Exception reporting mode: Plain</div>
<div class="gmail_extra">Doctest mode is: ON</div><div class="gmail_extra">>>> class Dad(object):</div><div class="gmail_extra"> def __str__(self):</div><div class="gmail_extra"> return "value={}".format(self.value)</div>
<div class="gmail_extra">...</div><div class="gmail_extra">>>> class Son(Dad):</div><div class="gmail_extra"> @property</div><div class="gmail_extra"> def value(self):</div><div class="gmail_extra"> return self._value</div>
<div class="gmail_extra"> @value.setter</div><div class="gmail_extra"> def value(self, value):</div><div class="gmail_extra"> self._value = value*2</div><div class="gmail_extra">...</div><div class="gmail_extra">
>>> def func(arg):</div><div class="gmail_extra"> arg.value = 15</div><div class="gmail_extra"> print(arg)</div><div class="gmail_extra">...</div><div class="gmail_extra">>>> func(Dad())</div>
<div class="gmail_extra">value=15</div><div class="gmail_extra">>>> func(Son())</div><div class="gmail_extra">value=30</div><div class="gmail_extra">>>></div><div><br></div></div>
</div></div>