[Numpy-discussion] confusion on importing numpy

mark markbak@gmail....
Wed Aug 6 16:00:52 CDT 2008


Thanks for the encouragement to try to dive deeper into namespaces,
but also thanks for the amin, amax suggestions.
Mark

On Aug 6, 8:21 pm, Eric Firing <efir...@hawaii.edu> wrote:
> mark wrote:
> > Hello list. I am confused about importing numpy.
>
> > When I do
>
> > from numpy import *
>
> > and I try the min function, I get the default Python min function.
>
> > On the other hand, when I do
>
> > import numpy as np
>
> > and use the np.min function, I get the numpy min function (which is
> > obviously what I want).
>
> > I know, the latter is preferred, but the former is so dang easy to
> > type.
> > I always thought both imports work the same, but I am obviously wrong.
> > What's the difference?
>
> While I agree with the other posters that "import *" is not preferred,
> if you want to use it, the solution is to use amin and amax, which are
> provided precisely to avoid the conflict.  Just as arange is a numpy
> analog of range, amin and amax are numpy analogs of min and max.
>
> Eric
>
>
>
> > Thanks, Mark
> > _______________________________________________
> > Numpy-discussion mailing list
> > Numpy-discuss...@scipy.org
> >http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discuss...@scipy.orghttp://projects.scipy.org/mailman/listinfo/numpy-discussion


More information about the Numpy-discussion mailing list