[Numpy-discussion] simple Numarray question
Todd Miller
jmiller at stsci.edu
Mon Jan 26 08:58:13 CST 2004
On Mon, 2004-01-26 at 11:38, Nancy Keuss wrote:
> Hi,
>
> What do I have to include in my Python file for Python to recognize Numarray
> functions? For instance, in a file called hello.py I try:
>
> a = arange(10)
> print a[1:5]
>
> and I get the error:
>
> Traceback (most recent call last):
> File "C:\Python23\hello.py", line 3, in ?
> a = arange(10)
> NameError: name 'arange' is not defined
>
There are a number of ways to import numarray (or any Python module),
but the way I recommend is this:
import numarray
a = numarray.arange(10)
print a[1:5]
If you're writing quick scripts that you're not worried about
maintaining, do this:
from numarray import *
a = arange(10)
print a[1:5]
If writing "numarray." is too tedious, but you still care about
maintenance, try something like this:
import numarray as _n
a = _n.arange(10)
print a[1:5]
Todd
> Thank you,
> Nancy
>
>
>
> -------------------------------------------------------
> The SF.Net email is sponsored by EclipseCon 2004
> Premiere Conference on Open Tools Development and Integration
> See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
> http://www.eclipsecon.org/osdn
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
--
Todd Miller <jmiller at stsci.edu>
More information about the Numpy-discussion
mailing list