Problem with string -> int conversion ?

Fredrik Lundh fredrik at pythonware.com
Wed Aug 31 00:33:53 CEST 2005


Madhusudan Singh wrote:

> I am working with an application that I designed with the Designer > pyuic
> workflow and I get the following error on trying to process the contents 
> of
> a combobox :
>
> Traceback (most recent call last):
>  File "measure.py", line 908, in acquiredata
>    np=self.getNPrange()
>  File "measure.py", line 1167, in getNPrange
>    signalrange=int(signalrangestr)
> TypeError: int() argument must be a string or a number
>
> The code is :
>
> void Form3::getNPrange()
> {

what language is this?

> signalrangestr=self.NPcombobox.currentText()
> signalrange=int(signalrangestr)
> if globaldebug : print 'NP Signal range = ',signalrange
> return signalrange
> }

> Isn't signalrangestr above a string ? Or at the very least, a number.

if the callback code is Python, you should be able to add a print
statement to the line just before the failing "int" call:

    print repr(signalrangestr), type(signalrangestr)
    signalrange = int(signalrangestr)

that print statement should be all you need to figure out what
signalrangestr really is.

</F> 






More information about the Python-list mailing list