Error importing __init__ declared variable from another package

Peter Otten __peter__ at
Tue Feb 28 03:31:38 EST 2012

Jason Veldicott wrote:

> Hi,
> I have a simple configuration of modules as beneath, but an import error
> is reported:
> /engine
>    (__init__ is empty here)
> /sim
> The module imports a variable instantiated in sim.__init__ as
> follows:
>    from sim import var_name
>    var_name.func()
> The following error messaged is received on the func() call above (Eclipse
> PyDev):
> "undefined variable from import: func"

Are you rephrasing or is this really the error message? If so run your 
program again on the command-line. Then please cut and paste the error 
message together with the traceback.

> Any idea why this is causing an error?

What version of Python are you using?
What does sim/ contain?

More information about the Python-list mailing list