Re: global name 'sqrt' is not defined

2009-02-09 Thread Rob
> Any ideas? If I do something like "import math" in the subfunction, > then the error changes to "global name 'math' is not defined". Presumably ipython does an import so you need to import it yourself something like: from math import sqrt at the top of your source file. I don't know why mat

Re: global name 'sqrt' is not defined

2009-02-05 Thread Robert Kern
On 2009-02-05 18:55, James Mills wrote: On Fri, Feb 6, 2009 at 10:48 AM, Nick Matzke wrote: (PS: Is there a way to force a complete reload of a module, without exiting ipython? Just doing the import command again doesn't seem to do it.) m = __import__("mymobile") reload(m) Or more straight

Re: global name 'sqrt' is not defined

2009-02-05 Thread James Mills
On Fri, Feb 6, 2009 at 10:48 AM, Nick Matzke wrote: > (PS: Is there a way to force a complete reload of a module, without exiting > ipython? Just doing the import command again doesn't seem to do it.) m = __import__("mymobile") reload(m) cheers James -- http://mail.python.org/mailman/listinfo/p

Re: global name 'sqrt' is not defined

2009-02-05 Thread Nick Matzke
OK, so the problem was that I had to exit ipython, re-enter it, and then import my module to get the errors to disappear. Thanks for the help! (PS: Is there a way to force a complete reload of a module, without exiting ipython? Just doing the import command again doesn't seem to do it.) Th

Re: global name 'sqrt' is not defined

2009-02-05 Thread Diez B. Roggisch
Nick Matzke schrieb: Scott David Daniels wrote: M.-A. Lemburg wrote: On 2009-02-05 10:08, Nick Matzke wrote: ..., I can run this in the ipython shell just fine: a = ["12", "15", "16", "38.2"] dim = int(sqrt(size(a))) ...But if I move these commands to a function in another file, it freaks o

Re: global name 'sqrt' is not defined

2009-02-05 Thread Nick Matzke
Scott David Daniels wrote: M.-A. Lemburg wrote: On 2009-02-05 10:08, Nick Matzke wrote: ..., I can run this in the ipython shell just fine: a = ["12", "15", "16", "38.2"] dim = int(sqrt(size(a))) ...But if I move these commands to a function in another file, it freaks out: You need to add:

Re: global name 'sqrt' is not defined

2009-02-05 Thread Scott David Daniels
M.-A. Lemburg wrote: On 2009-02-05 10:08, Nick Matzke wrote: ..., I can run this in the ipython shell just fine: a = ["12", "15", "16", "38.2"] dim = int(sqrt(size(a))) ...But if I move these commands to a function in another file, it freaks out: You need to add: from math import sqrt or:

Re: global name 'sqrt' is not defined

2009-02-05 Thread M.-A. Lemburg
On 2009-02-05 10:08, Nick Matzke wrote: > Hi all, > > So, I can run this in the ipython shell just fine: > > === > a = ["12", "15", "16", "38.2"] > dim = int(sqrt(size(a))) > > dim >>2 > === > > > But if I move these commands to a function in another file, it freaks out: You n

Re: global name 'sqrt' is not defined

2009-02-05 Thread Chris Rebert
On Thu, Feb 5, 2009 at 1:08 AM, Nick Matzke wrote: > Hi all, > > So, I can run this in the ipython shell just fine: > > === > a = ["12", "15", "16", "38.2"] > dim = int(sqrt(size(a))) sqrt() is not a builtin function, it's located in the 'math' module. You must have imported it at some po