对命名空间感到困惑

对命名空间感到困惑

本文介绍了对命名空间感到困惑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 大家好, 开始,对不起,我还在学习编程, 可能我正在制作一些基础知识这里的错误... 我在同一个 目录中有文件settings.py,GUIclasses.py和main.py.在main.py文件中是声明: 导入设置来自GUIclasses导入的 * 类Toepassing (wx.App): def OnInit(个体经营): window = KFrame(无,Testerdetest,(1000,900)) self.SetTopWindow(窗口) window.Show(True) 返回True app = Toepassing(无) app.MainLoop() 在GUIclasses.py文件中我有以下声明: import wx 导入wx.lib.mixins.listctrl作为listmix 类KFrame(wx.Frame): def __init __(自我,父母,标题,大小): ...一些代码... self.lst = settings.attrLijst .. ..更多代码...... 现在,如果我运行main.py文件,我会收到错误: 文件G:\Programmeren \Codes contactenlijst\GUIclasses.py,第40行, in __init_ _ self。 lst = settings.a ttrLijst NameError:名称''settings''未定义 为什么会这样?由于来自GUIclasses import *这个KFrame现在处于 最低的范围内。命名空间,因此应该能够使用生活在那里的任何 变量,包括settings。*,no? 提前致谢! - 基斯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 samedirectory. In the file main.py are the statements:import settingsfrom GUIclasses import *class Toepassing(wx.App):def OnInit(self):window = KFrame(None, "Testerdetest", (1000,900))self.SetTopWindow(window)window.Show(True)return Trueapp = Toepassing(None)app.MainLoop()In the file GUIclasses.py I have the statements:import wximport wx.lib.mixins.listctrl as listmixclass 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.attrLijstNameError: name ''settings'' is not definedWhy is this? Since "from GUIclasses import *" this KFrame is now at"the lowest" namespace and should therefore be able to make use of anyvariables living there, including "settings.*", no?Thanks in advance!- Kees推荐答案 这篇关于对命名空间感到困惑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-28 06:28