Re: Please Explain This Error
Rich Shepard <[email protected]>
| Newsgroups | gmane.comp.python.db.pysqlite.user |
|---|---|
| Message-ID | <[email protected]> |
On Fri, 3 Nov 2006, [email protected] wrote: > The easiest way to do something like this is to have a class that you > create, then reference the variable in the class as in: > > class foo: > myvariable = 12 > > from foo import myvariable > class why: > def printmyvariable(self): > print myvariable Greg, This is the circular trap I'm in. I suppose that I did not clearly explain the situation so I'll try again using your example above. Class foo has all the wxPython UI code and the application's top-level window. In there, on one notebook page, is a wx.TextCtrl() widget in which the user enters the new or existing project name. That's assigned to the variable, 'projname.' There are other bound methods in foo that require access to the sqlite3 project database for writing and retrieving. Therefore, foo imports class why because that's where the database open/create/close functions are now located. Class why has the openDB() and closeDB() functions. They need the 'projname' variable to reference the file they are to open, create, or close. I cannot import projname from foo because foo imports class why. In C, I'd define projname in class foo, then declare it 'extern projname' in class why. I don't know the python equivalent of this. Is this any more clear now? Thanks very much, Rich -- Richard B. Shepard, Ph.D. | The Environmental Permitting Applied Ecosystem Services, Inc.(TM) | Accelerator <http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863