[python-win32] Problem with built-in str() function

John Hopkins john@hopkinsit.com
Mon, 10 Jun 2002 19:53:12 -0700


This is a multi-part message in MIME format.

------=_NextPart_000_001C_01C210B8.73B565D0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

The other day, str() "stopped working" for me. Here's what I mean.

I have this bit of code in a wxPython app:

        for x in range(len(items)):
            DateValue =3D items[x][1]
            if DateValue !=3D 'N/A':
                DisplayDate =3D '%s/%s/%s' % =
(DateValue[5:7],DateValue[8:10],DateValue[0:4])
            else:
                DisplayDate =3D DateValue
            self.SearchList.InsertStringItem(x, items[x][0])
            self.SearchList.SetStringItem(x, 1, DisplayDate)
            print 'items[x][2] =3D %s' % items[x][2]
            self.SearchList.SetStringItem(x, 2, str(items[x][2]))
            self.SearchList.SetItemData(x, items[x][2])

Often as not the loop only iterates once (the list only has a single =
element).  When this line executes:

            self.SearchList.SetStringItem(x, 2, str(items[x][2]))

I get the following output:

items[x][2] =3D 3
Traceback (most recent call last):
  File "LabTracker_Dev.py", line 356, in OnFindClick
    self.SearchList.SetStringItem(x, 2, str(items[x][2]))
TypeError: 'str' object is not callable

 This is so basic that I'm utterly lost.

I feel silly, but can anybody help me with this?

Thanks,

John


------=_NextPart_000_001C_01C210B8.73B565D0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2716.2200" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>The other day, str() "stopped working" =
for me.=20
Here's what I mean.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I have this bit of code in a wxPython=20
app:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for x in=20
range(len(items)):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;=20
DateValue =3D=20
items[x][1]<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;=20
if DateValue !=3D=20
'N/A':<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;=20
DisplayDate =3D '%s/%s/%s' %=20
(DateValue[5:7],DateValue[8:10],DateValue[0:4])<BR>&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
else:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;=20
DisplayDate =3D=20
DateValue<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;=20
self.SearchList.InsertStringItem(x,=20
items[x][0])<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;=20
self.SearchList.SetStringItem(x, 1,=20
DisplayDate)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;=20
print 'items[x][2] =3D %s' %=20
items[x][2]<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;=20
self.SearchList.SetStringItem(x, 2,=20
str(items[x][2]))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;=20
self.SearchList.SetItemData(x, items[x][2])<BR></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Often as not the loop only iterates =
once (the list=20
only has a single element).&nbsp;&nbsp;When this line =
executes:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;=20
self.SearchList.SetStringItem(x, 2, str(items[x][2]))<BR></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I get the following =
output:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>items[x][2] =3D 3<BR>Traceback (most =
recent call=20
last):<BR>&nbsp; File "LabTracker_Dev.py", line 356, in=20
OnFindClick<BR>&nbsp;&nbsp;&nbsp; self.SearchList.SetStringItem(x, 2,=20
str(items[x][2]))<BR>TypeError: 'str' object is not =
callable</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;This is so basic that I'm utterly =

lost.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I feel silly, but can anybody help me =
with=20
this?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>John</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;</DIV></FONT></BODY></HTML>

------=_NextPart_000_001C_01C210B8.73B565D0--