I came from Java. I have a variable in a class that I need to change in more than one method.
I tried to put it global, but it consumed a lot of resources.
How do I change var
of another class in Django?
var = 0
def metodo1():
var += 1
def metodo2():
var += 10
[ Resolved ]
Thanks for your colleague's reply below. I have decided as follows: I created a 'static' class:
class Modulo(object):
andamento_processo = 0
def processo(self):
self.andamento_processo = 1
Now I instantiate it from the other class and change the value when it needs it, it literally looks like a static (java) variable!
class NovaClasse:
Modulo.andamento_processo = 10