[Tutor] Confused about "import Numeric" vs "import numpy" for Arrays

Timothy Grant timothy.grant at gmail.com
Fri Aug 8 19:25:43 CEST 2008


On Fri, Aug 8, 2008 at 9:29 AM, S Python <spython01 at gmail.com> wrote:
>> No, they are not the same. Numeric is older; NumArray is another older
>> package. You should use Numpy if you can.
>> http://numpy.scipy.org/#older_array
>>
> <snip>
>>
>> Now you should be able to import numpy.
>>
>> Kent
>>
>
> Thanks, Kent.  I ended up using:
>>>> from numpy import *
>
> I wasn't sure what the difference was between this and
>>>> import numpy
>
> Thanks!
>
> Samir

In general "from <module> import *" is a very bad idea.

import <module> imports a module into its own namespace (e.g., to
access its functionality you would have to do "<module>.foo() and
<module>.bar()" The form that you chose to use imports all of a
module's contents into the current namespace. This means you can call
"foo()" and "bar()" directly, but it also means that if you have coded
a "foo()" and a "bar()" you will not have access to the functions in
the module you just imported.




-- 
Stand Fast,
tjg. [Timothy Grant]


More information about the Tutor mailing list