Problem with string -> int conversion ?

Madhusudan Singh spammers-go-here at spam.invalid
Tue Aug 30 18:22:12 EDT 2005


Hi

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()
{
signalrangestr=self.NPcombobox.currentText()
signalrange=int(signalrangestr)
if globaldebug : print 'NP Signal range = ',signalrange
return signalrange
}

The contents of the combobox are strings representing numbers in the range
[0,6].

Isn't signalrangestr above a string ? Or at the very least, a number. I
entered these numbers myself in designer, so they do not have any
white-space (len(signalrangestr) returns 1). In any case, an attempt to use
strip() fails with :

Traceback (most recent call last):
  File "measure.py", line 908, in acquiredata
    np=self.getNPrange()
  File "measure.py", line 1169, in getNPrange
    signalrange=int(signalrangestr.strip())
AttributeError: strip




More information about the Python-list mailing list