En realidad en Python todo son punteros he aquí una prueba sencilla:
In Python all are pointers here's a simple example:
They point to different positions, but ....
TACHAN! B has the same position as A. But if we change B, A does not change. To simulate this we have to do ...
In Python all are pointers here's a simple example:
a=1 id(a) # posicion 11111 b=2 id(b) # posicion 22222Los dos apuntan a posiciones distintas, pero....
They point to different positions, but ....
id(a) # posicion 11111 b=a id(b) # posicion 11111TACHAN!!! B apunta a la misma posición que A. De todas formas si ahora modificamos el valor de B el valor de A no varía. Para lograr simular un puntero de verdad. Tenemos que hacer el siguiente apaño.
TACHAN! B has the same position as A. But if we change B, A does not change. To simulate this we have to do ...
class ref:
def __init__(self, obj): self.obj = obj
def get(self): return self.obj
def set(self, obj): self.obj = obj
a = ref(1)
b = a
print a.get() # 1
print b.get() # 1
b.set(2)
print a.get() # => 2
print b.get() # => 2
happy coding ;)