problem with appending to a list, possibly mysqldb related
John Salerno
johnjsal at NOSPAMgmail.com
Thu Aug 31 14:11:15 EDT 2006
Here's the code:
class MyFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, wx.ID_ANY)
panel = wx.Panel(self)
dbconn = self.connect_db()
dbconn.execute("select namefirst, namelast from master")
bb_players = []
for x in dbconn.fetchall():
bb_players.append(' '.join(x))
cb = PromptingComboBox(panel, 'Choose A Player',
choices=bb_players, style=wx.CB_SORT)
def connect_db(self):
connection = MySQLdb.connect('localhost', 'john', '*******',
'bbdatabank')
return connection.cursor()
The error seems to be in the for loop. I get this:
Traceback (most recent call last):
File "C:\Python24\myscripts\bbdata_access\bbdata.py", line 71, in
-toplevel-
app = MyApp(False)
File "C:\Python24\Lib\site-packages\wx-2.6-msw-ansi\wx\_core.py",
line 7700, in __init__
self._BootstrapApp()
File "C:\Python24\Lib\site-packages\wx-2.6-msw-ansi\wx\_core.py",
line 7352, in _BootstrapApp
return _core_.PyApp__BootstrapApp(*args, **kwargs)
File "C:\Python24\myscripts\bbdata_access\bbdata.py", line 64, in OnInit
frame = MyFrame()
File "C:\Python24\myscripts\bbdata_access\bbdata.py", line 15, in
__init__
name = ' '.join(x)
TypeError: sequence item 0: expected string, NoneType found
>>>
I know the method of joining the items in the tuple and appending to a
list work, so I figure it has something to do with either mysqldb, or
maybe the PromptingComboBox I am using.
Hope someone can spot the problem!
Thanks,
John
More information about the Python-list
mailing list