[Numpy-discussion] str == int puzzlement

John Salvatier jsalvati@u.washington....
Wed Jul 28 20:49:17 CDT 2010


I think this is just Python behavior; comparing python ints and strs also
gives False:

In [45]: 8 == 'L'
Out[45]: False


On Wed, Jul 28, 2010 at 6:42 PM, Matthew Brett <matthew.brett@gmail.com>wrote:

> Hi,
>
> Please forgive me if this is obvious, but this surprised me:
>
> In [15]: x = np.array(['a', 'b'])
>
> In [16]: x == 'a'  # this was what I expected
> Out[16]: array([ True, False], dtype=bool)
>
> In [17]: x == 1 # this was strange to me
> Out[17]: False
>
> Is it easy to explain why this is?
>
> Thanks a lot,
>
> Matthew
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20100728/d1365034/attachment.html 


More information about the NumPy-Discussion mailing list