Fhernd icon

delegar_acceso_atributo.py

Fhernd | PRO | 01/07/19 06:30:00 PM UTC | 0 ⭐ | 1872 👁️ | Never ⏰ | []
Python |

480 B

|

None

|

0 👍

/

0 👎

class Calculadora:
    def sumar(self, a, b):
        return a + b
 
    def restar(self, a, b):
        return a - b
 
 
class CalculadoraCientifica:
    def __init__(self):
        self._calculadora = Calculadora()
 
    def potencia(self, a, b):
        return a ** b
 
    def __getattr__(self, atributo):
        return getattr(self._calculadora, atributo)
 
 
calc = CalculadoraCientifica()
 
print(calc.potencia(5, 2))
print(calc.sumar(3, 2))
print(calc.restar(3, 2))

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎