trying to populate my list from my sqlite database

Dolamite Jenkins
Dolamite Jenkins used Ask the Experts™
on
im trying to populate my wx.Choice Widget from my database ... I keep getting TypeError:__init__() should return None not 'List'

what am I doing wrong


con = lite.connect('eventpreplannerII.sqlite')
            cur = con.cursor()
            cur.execute("select * from eventinfoII" )
        
            rows=cur.fetchall()
            #print rows
            rRows=[]
            for row in rows:
                s={}
                s['Nameofevent']  =row['nameofevent'] 
            
                self.nameofevet1 = s['nameofevent']
                wx.Choice(self,-1,(85,85), choices = self.nameofevet1)
                rRows.append(s)
            return rRows
        except lite.Error, error:
            dlg = wx.MessageDialog(self, str(error), 'Error occured')
            dlg.ShowModal()

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
What you are doing wrong is that you are trying to return a value from the __init__ method of a class and that you cannot do. The __init__ method should not return anything to put it in Van Rosum (actually it returns an instantiated object).

So remove row 15th to get rid of that error (and any other rows you may have and not seen here with explicit return values in the __init__ method):

#return rRows

and to quote Guido: "a property that I quite like: if classname(...) returns, it returns an instance of class 'classname'. If you don't want that, it shouldn't be a class. Note that C++ constructors can't return a value either..."

That is the answer to your question, however I see other other problems in your code, mainly typos that you could get rid of them easily once you move on from this error.

Author

Commented:
solved that error

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial