I'm doing a code and this happens to me:
First I made this class with the intention of using it as if it were a structure of those of C and C ++
class Data:
titulo = []
id = []
fecha=[]
Then I did a function where I gave values to the members
def funcion1():
vd = Data()
#aquí va algo de código pero no es relevante
vd.id.append(id)
vd.titulo.append(title)
vd.fecha.append(date)
Then I did another function that has nothing to do with the first and that I wanted to use again an object of the type Data () (different object).
def funcion2():
vdn = Data()
#aquí va algo de código pero no es relevante
for k in range( len(vdn.id) ):
print("%s" % vdn.titulo[k])
The issue is that something is happening that I did not expect and that does not interest me. In function2 (), vdn is taking the values I gave to vd in function1 (). That is, it is behaving like a global variable, even giving it a different name.
Is there any way to prevent this from happening? I'm interested in using only local variables.