Is it by design that  "numpy.sqrt(None)" raises an "AttributeError: sqrt"?

This was confusing because there was an attribute lookup of 'sqrt' in
numpy right there in the expression I typed, but that was not the
attribute that python was complaining about.  I presume that numpy.sqrt
didn't know what to do with None, so it looked up a .sqrt in it or
something... but I presume this only in hindsight now that I figured
out the problem--I didn't mean to take the sqrt of None in the first place.

How about adding some information to the AttributeError, such
as the object on which the lookup failed (here None, as opposed to the
numpy module).

Now I'm off to delete all the getattr(numpy, 'sqrt') calls I littered
through a few files...

James
--
http://www-etud.iro.umontreal.ca/~bergstrj




-- 
http://www-etud.iro.umontreal.ca/~bergstrj
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to