[Tutor] Convert values in a list back and forth from ints

Andre Engels andreengels at gmail.com
Wed Jan 7 10:51:56 CET 2009


On Wed, Jan 7, 2009 at 9:45 AM, prasad rao <prasadaraon50 at gmail.com> wrote:

> 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

'class' should not start with a capital. I do by the way wonder what
your code is supposed to accomplish - why have arguments inte and stri
for setvalue when you don't use them (you use the existing value of
self.stri).



-- 
André Engels, andreengels at gmail.com


More information about the Tutor mailing list