Converting Unicode to integer

Terry Reedy tjreedy at udel.edu
Tue Aug 27 15:34:20 EDT 2002


"Nikola Plejic" <Nikola.Plejic at pu.CARNet.hr> wrote in message
news:akgd1s$lmf$1 at bagan.srce.hr...
> def handler(**kw):
>     a = txt.text
>     b = txt2.text
>     a = int(a)
>     b = int(b)
>     lbl.text = a + b

You here try to set lbl.txt to an int.

>   File "C:\Python22\test2.py", line 8, in handler
>     lbl.text = a + b
>   File "C:\Python22\Lib\site-packages\anygui\Mixins.py", line 137,
in
> __setattr__
>     inhibit_refresh = setter(value)
>   File "C:\Python22\Lib\site-packages\anygui\Labels.py", line 15, in
> _set_text
>     text = text.replace('\r\n', ' ')
> AttributeError: 'int' object has no attribute 'replace'

Appears you can't do that.  Appears lbl.text must be a string -- which
has replace method -- not an int, which does not.  Try lbl.text =
str(a+b) instead.

TJR






More information about the Python-list mailing list