Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- class prueba:
- def __init__(self):
- self.lista = []
- def anadir(self, v):
- self.lista.append(v)
- def anadir_varios(self, v):
- for a in v:
- prueba.anadir(self, a)
- class prueba2(prueba):
- def __init__(self):
- super().__init__()
- self.contador = 0
- def anadir(self, v):
- super().anadir(v)
- self.contador += 1
- def anadir_varios(self, v):
- super().anadir_varios(v)
- self.contador += len(v)
- p = prueba2()
- p.anadir_varios([1, 2, 3])
- print("Cantidad: {:}".format(p.contador))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement