Enivob opened this issue on Nov 29, 2006 · 4 posts
nruddock posted Wed, 29 November 2006 at 1:47 PM
Weird one, but there is a solution.
import __builtin__ as bi<br></br>import Blender as B<br></br>class myAdder:<br></br> def __init__(self):<br></br> self.localVal = 0<br></br><br></br> def addValue(self):<br></br> self.localVal = self.localVal + 1<br></br><br></br> def getValue(self):<br></br> return self.bi.str(self.localVal)<br></br><br></br>try:<br></br> ma = B.myClass<br></br> ma.addValue()<br></br>except:<br></br> ma = myAdder()<br></br> ma.bi = bi<br></br> B.myClass = ma<br></br><br></br>print ma.getValue()
If you don't return a string value from myAdder.getValue() everything would work without any messing around.
import Blender as B
class myAdder:
def init(self):
self.localVal = 0
def addValue(self):
self.localVal = self.localVal + 1
def getValue(self):
return self.localVal
try:
ma = B.myClass
ma.addValue()
except:
ma = myAdder()
B.myClass = ma
print ma.getValue()
If your catching an exception, then it's a good idea, while developing to still print the exception out using
import traceback
traceback.print_exc()
just in case you run into something weird.