Confused about namespaces

KvS keesvanschaik at gmail.com
Fri Nov 18 18:04:23 EST 2005


Hi all,

to start with, excuse me, I'm still learning programming alltogether,
probably I'm making some fundamental mistake here...

I have the files settings.py, GUIclasses.py and main.py in the same
directory. In the file main.py are the statements:

import settings
from GUIclasses import *

class Toepassing(wx.App):
	def OnInit(self):
		window = KFrame(None, "Testerdetest", (1000,900))
		self.SetTopWindow(window)
		window.Show(True)
		return True

app = Toepassing(None)
app.MainLoop()

In the file GUIclasses.py I have the statements:

import wx
import wx.lib.mixins.listctrl  as  listmix

class KFrame(wx.Frame):
	def __init__(self, parent, title, Size):
                ...some code...
                self.lst = settings.attrLijst
                ....some more code......

Now if I run the main.py file I get the error:

  File "G:\Programmeren\Codes contactenlijst\GUIclasses.py", line 40,
in __init_
_
    self.lst = settings.attrLijst
NameError: name 'settings' is not defined

Why is this? Since "from GUIclasses import *" this KFrame is now at
"the lowest" namespace and should therefore be able to make use of any
variables living there, including "settings.*", no?

Thanks in advance!

- Kees




More information about the Python-list mailing list