[IPython-User] question about extensions
Thomas Kluyver
takowl@gmail....
Wed Oct 17 16:24:58 CDT 2012
On 17 October 2012 19:38, Michael Kuhlen <kuhlen@gmail.com> wrote:
> In [6]: import test as t
>
> In [7]: t.test()
> ---------------------------------------------------------------------------
> NameError Traceback (most recent call last)
> <ipython-input-6-f69a6e70fa4a> in <module>()
> ----> 1 t.test()
>
> /home/mqk/test.py in test()
> 1 def test():
> ----> 2 print Q('1 hplanck').base
>
> NameError: global name 'Q' is not defined
Your test module has a separate namespace from the shell, so functions
loaded or defined inside IPython aren't accessible inside a module
you've imported. But IPython extensions are just modules, so if you
put the physics.py file on your Python path, you should be able to
import it in test.py.
Thomas
More information about the IPython-User
mailing list