You've already forked Curso-lenguaje-python
Update Python Ofensivo
This commit is contained in:
17
python-ofensivo/00_ejercicios/05_encapsulamiento07.py
Normal file
17
python-ofensivo/00_ejercicios/05_encapsulamiento07.py
Normal file
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Métodos especiales
|
||||
"""
|
||||
|
||||
|
||||
class MiLista:
|
||||
|
||||
def __init__(self):
|
||||
self.data = [1, 2, 3, 4, 5]
|
||||
|
||||
def __getitem__(self, index):
|
||||
return self.data[index]
|
||||
|
||||
lista = MiLista()
|
||||
|
||||
print(lista[2])
|
||||
Reference in New Issue
Block a user