Error importing __init__ declared variable from another package
Hi, I have a simple configuration of modules as beneath, but an import error is reported: /engine (__init__ is empty here) engine.py /sim __init__.py The module engine.py 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" Any idea why this is causing an error? -- http://mail.python.org/mailman/listinfo/python-list
Re: Error importing __init__ declared variable from another package
Accidentally hit post by mistake before msg completed. Any comments appreciated. It's a very simple scenario, but not sure what the mistake is. Thanks Jason On Tue, Feb 28, 2012 at 6:55 PM, Jason Veldicott wrote: > Hi, > > I have a simple configuration of modules as beneath, but an import error > is reported: > > /engine >(__init__ is empty here) >engine.py > /sim >__init__.py > > > The module engine.py 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" > > Any idea why this is causing an error? > -- http://mail.python.org/mailman/listinfo/python-list
Re: Error importing __init__ declared variable from another package
Jason Veldicott wrote: > Hi, > > I have a simple configuration of modules as beneath, but an import error > is reported: > > /engine >(__init__ is empty here) >engine.py > /sim >__init__.py > > > The module engine.py 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/__init__.py contain? -- http://mail.python.org/mailman/listinfo/python-list
Re: Error importing __init__ declared variable from another package
> > > Hi, > > > > I have a simple configuration of modules as beneath, but an import error > > is reported: > > > > /engine > >(__init__ is empty here) > >engine.py > > /sim > >__init__.py > > > > > > The module engine.py 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/__init__.py contain? Thanks Peter. I'm using Python 2.6, but it works at the command line. The error only appears in Eclipse as a red cross in the margin. The exact error msg, as appears in a floating text caption on mouse over, is as I mentioned (capitalised). Perhaps it is some issue in PyDev, maybe related to the version of Python I'm using. I'm in the process of trying to solve another related import problem, and wished to resolve this one in the hope that it might shed light on the other. But as it works beside the error icon appearing, I might just ignore it and spare the trouble of precise identification of cause. Jason -- http://mail.python.org/mailman/listinfo/python-list
Re: Error importing __init__ declared variable from another package
On Wed, Feb 29, 2012 at 1:38 AM, Jason Veldicott wrote: >> > Hi, >> > >> > I have a simple configuration of modules as beneath, but an import error >> > is reported: >> > >> > /engine >> > (__init__ is empty here) >> > engine.py >> > /sim >> > __init__.py >> > >> > >> > The module engine.py 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/__init__.py contain? > > > > Thanks Peter. > > I'm using Python 2.6, but it works at the command line. The error only > appears in Eclipse as a red cross in the margin. The exact error msg, as > appears in a floating text caption on mouse over, is as I mentioned > (capitalised). > > Perhaps it is some issue in PyDev, maybe related to the version of Python > I'm using. > > I'm in the process of trying to solve another related import problem, and > wished to resolve this one in the hope that it might shed light on the > other. But as it works beside the error icon appearing, I might just ignore > it and spare the trouble of precise identification of cause. Please report that as a bug in the PyDev sf tracker (please attach a sample project where this problem can be reproduced). Cheers, Fabio -- http://mail.python.org/mailman/listinfo/python-list