Re: Please Explain This Error

Rich Shepard <[email protected]>
Newsgroups gmane.comp.python.db.pysqlite.user
Message-ID <[email protected]>
On Thu, 2 Nov 2006, Rich Shepard wrote:

>   I'm going to recreate dbMethods.py with one class that holds the
> openDB() (opens the database, or creates a new one if that name does not
> exist) and the closeDB(). It almost worked before, this time I'll make
> sure it does. This is more sensible than fighting to figure out why
> 'self.cur.execute(...' works in some modules and not others.

   Well, I hit the same problem as before, but this time I want to learn how
to do the job.

   In the new module, dbMethods.py, the variable named 'projname' is used as
the stem of the database name (projname.db). However, 'projname' is declared
and defined in a totally separate module, class, and function. It is
obtained as user input in a wxPython widget.

   My understanding of variable scope is that 'projname' is local to the
function in which it is defined (OnFileNew, in this case), and global within
the class (MainFrame). My search of the slew of python books on the shelf
here does not reveal how I can make this variable visible across modules.

   I cannot import the module with the class MainFrame because that module
imports dbMethods. An infinite loop. Checkmate. There's gotta' be a way to
do this, but I'm too new at python to know how.

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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.