[Numpy-discussion] Style for pad implementation in 'pad' namespace or functions under np.lib

Chris Barker chris.barker@noaa....
Thu Mar 29 11:09:07 CDT 2012


On Thu, Mar 29, 2012 at 7:55 AM, Tim Cera

>> I think there is also a question of using a prefix pad_xxx for the
>> function names as opposed to pad.xxx.

"Namespaces are one honking great idea -- let's do more of those!"


> If I had it as pad.mean, pad.median, ...etc. then someone could
>
>     from numpy.pad import *
>     a = np.arange(5)
>     # then you would have a confusing
>     b = mean(a, 2)

exactly why no one should *ever* do import *!

pad.mean

is not more typing than

pad_mean

so there in NO reason to use the latter, except to have a C style,
rather than python namespaces....

ANd what if someone DOES want to override mean?:

from np.pad import mean

and now they can do

mean(something)

and it's explicite what they mean to do.

-Chris

-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker@noaa.gov


More information about the NumPy-Discussion mailing list