2014-06-03 22:37 GMT+02:00 Piergiuliano Bossi <pgbo...@gmail.com>:

> Questa non puo' funzionare, invoco func anche con un Dad().


ahahah ma l'hai provata?
sarĂ  una delle magie di python?

In [6]: %doctest_mode
Exception reporting mode: Plain
Doctest mode is: ON
>>> class Dad(object):
    def __str__(self):
                return "value={}".format(self.value)
...
>>> class Son(Dad):
    @property
    def value(self):
        return self._value
    @value.setter
    def value(self, value):
        self._value = value*2
...
>>> def func(arg):
        arg.value = 15
        print(arg)
...
>>> func(Dad())
value=15
>>> func(Son())
value=30
>>>
_______________________________________________
Python mailing list
Python@lists.python.it
http://lists.python.it/mailman/listinfo/python

Rispondere a