Skip to content

Instantly share code, notes, and snippets.

@bniebuhr
Last active May 24, 2016 13:37
Show Gist options
  • Save bniebuhr/8678d67384d09df5b30f627a701f14fa to your computer and use it in GitHub Desktop.
Save bniebuhr/8678d67384d09df5b30f627a701f14fa to your computer and use it in GitHub Desktop.
how do I change Instance inernal variables, so that they ma be used by the class internal functions?
class Classe():
def __init__(self):
Classe.var1 = 10
Classe.var2 = 3
def printClasse(self):
print 'multiply = ' + str(Classe.var1*Classe.var2)
class_instance = Classe()
class_instance.printClasse() # shows 30, ok
class_instance.var1 = 20
class_instance.printClasse() # shows 30, not 60!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment