class - python - setting instance variable within the instance -


i have following tile class got instance variables such unmapped,free etc. instance variables default value once new instance created, want set of variables method within instance itself. when im trying so, seems the new value not saved when im doing without method seems work. how can be?

class tile():     def __init__(self):        self.free        =  0        self.unmapped    =  1     def set_tile(self,newval):        self.free = newval 

so : tile1 = tile() tile1.set_tile(20) -> tile1.free = 0 but, tile1.free = 20 -> tile1.free = 20

thanks help


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -