On Mon, Apr 23, 2012 at 11:29 AM, Julio Sergio <julioser...@gmail.com> wrote:
> I want to use the sign function. When I use it in in-line mode works pretty
> well:
>
>   : sign(-20)
>   : -1
>
> However, I wrote the following code in a file, say, pp.py
>
> def tst(x):
>    s = sign(x)
>    return(s)
>
> Then I tried to import into my session:
>
>  : from pp import *
>
> When I try to use tst, this is what I get:
>
>  ------------------------
>  Traceback (most recent call last):
>    File "<ipython console>", line 1, in <module>
>    File "pp.py", line 9, in tst
>      s = sign(x)
>  NameError: global name 'sign' is not defined
>
>
> Do you have any idea why is this happening?

There is no built-in sign() function in Python. It must be coming from
some library that you imported. You need to add that import to pp.py
so that Python knows that your module depends on that library.

Cheers,
Chris
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to