.>>>> class Value:.... def __init__(self, vs = ""): >... self.vs = vs >... self.v = self.asInt() >... def asInt(self): >... try: self.v = int(self.vs) >... except: self.v = None >... return self.v >... def asString(self): >... vs = str(self.vs) >... return self.vs >... def setStringValue(self, s): >... self.vs = s >... self.asInt() >... def setIntValue(self, i): >... self.v = int(i) >... self.vs = str(self.v)
hello Sorry to interject. This class seems asymmetric. Class Value: def __init__(self,inte='',stri=''): self.inte=inte self.stri=stri def setvalue(inte='',stri=''): self.stri=str(self.inte) self.int=int(self.stri) I tried. But failed.What is wrong with above code? >>> Class Value: def __init__(self,inte='',stri=''): self.inte=inte self.stri=stri def setvalue(inte='',stri=''): self.stri=str(self.inte) self.int=int(self.stri) SyntaxError: invalid syntax Prasad
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor