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: balar...@lanl.gov<mailto:balar...@lanl.gov>

Correspondence /
Technical data or Software Publicly Available



_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to