You've already forked Curso-lenguaje-python
Update Python Ofensivo
This commit is contained in:
22
python-ofensivo/00_ejercicios/05_encapsulamiento08.py
Normal file
22
python-ofensivo/00_ejercicios/05_encapsulamiento08.py
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Métodos especiales
|
||||
"""
|
||||
|
||||
|
||||
class Saludo:
|
||||
|
||||
def __init__(self, saludo):
|
||||
|
||||
self.saludo = saludo
|
||||
|
||||
def __call__(self, nombre):
|
||||
|
||||
return f"{self.saludo} {nombre}!"
|
||||
|
||||
|
||||
hola = Saludo("¡Hola")
|
||||
|
||||
print(hola("Luis"))
|
||||
|
||||
print(hola("Juan"))
|
||||
Reference in New Issue
Block a user