global name 'sqrt' is not defined

Chris Rebert crebert at
Thu Feb 5 10:19:44 CET 2009

On Thu, Feb 5, 2009 at 1:08 AM, Nick Matzke <matzke at> 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 point.
Or it could be be getting imported without your direct knowledge
through ~/, $PYTHONSTARTUP, and/or by doing 'import user'
For that matter, size() is not built into Python either, so you're
definitely importing these things somewhere.

Adding explicit imports of the modules/functions in question to the
top of the file(s) in question should fix the problem.


Follow the path of the Iguana...

More information about the Python-list mailing list