[Numpy-discussion] frompyfunc question

Larsen, Brian A balarsen@lanl....
Wed Jun 20 15:32:14 CDT 2012


Hello all,

I was looking to wrap hasattr in a numpy ufunc and got some weird behavior.

Here is a transcript:
In [5]: import numpy as np
In [6]: np.__version__
Out[6]: '1.6.2'
In [7]: b = [1,2,3]
In [7]: nphas = np.frompyfunc(hasattr, 2, 1)
In [8]: hasattr(b, 'extend')
Out[8]: True
In [9]: nphas(b, 'extend')
Out[9]: NotImplemented
In [10]: nphas(b, ['extend']*2)
Out[10]: NotImplemented
In [11]: type(nphas(b, ['extend']*2))
Out[11]: NotImplementedType


This isn't an exception but an object returned, what what or why is not implemented?

What I really want to do is be able to run hasattr like isinstance is run, isinstance(b, (list, str))


Anyone have any thoughts/advice here?

Cheers,

Brian










--

Brian A. Larsen
ISR-1 Space Science and Applications
Los Alamos National Laboratory
PO Box 1663, MS-D466
Los Alamos, NM 87545
USA

(For overnight add:
SM-30, Bikini Atoll Road)

Phone: 505-665-7691
Fax:   505-665-7395
email: balarsen@lanl.gov<mailto:balarsen@lanl.gov>

Correspondence /
Technical data or Software Publicly Available



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20120620/26c22ea0/attachment.html 


More information about the NumPy-Discussion mailing list