[PLUG] Local Python Help?

Paul Mullen pm at nellump.net
Thu Sep 27 22:50:06 UTC 2007


On Thu, Sep 27, 2007 at 03:11:03PM -0700, Rich Shepard wrote:
> 
>      from variablePage import curVar, UoDlow, UoDhigh
> ImportError: cannot import name curVar
> 
>    I've also tried
> 
> import variablePage as VP
> 
>    and referenced the variables as VP.curVar, VP.UoDlow, and VP.UoDhigh, but
> python still doesn't like this:
> 
>    File "/data1/eikos/fuzSetPage.py", line 364, in loadParVar
>      first = VP.curVar
> AttributeError: 'module' object has no attribute 'curVar'

Python is telling you that the variables you're trying to import are
not at the root level of the module. Are they actually contained
within a class? Bear in mind that in Python, a "module" is just
container for source code. All sorts of data structures can live
within a single module.

If 'curVar' is really a class attribute, you'll have to either import
the class:
  from variablePage import happyFunClass
  print happyFunClass.curVar

Or just import the entire module and access the class attribute the
long way:
  import variablePage
  print variablePage.happyFunClass.curVar


-- 
Paul



More information about the PLUG mailing list