[Numpy-discussion] comparing string array with None raises ValueError

Todd Miller jmiller at stsci.edu
Thu Jun 24 13:11:10 CDT 2004

On Thu, 2004-06-24 at 15:26, David M. Cooke wrote:
> On June 24, 2004 01:46 pm, Sebastian Haase wrote:
> > In general it must be OK to compare anything with None, right ?
> > (BTW, I get the same error with == and !=)
> No! Not in general! 

Well,  this is a good point.  I think the current numerical behavior was
a hack I stuck in for people who might not be aware of "is".  It's
looking like a mistake now.

> I learnt this back when Numeric implemented rich 
> comparisions; suddenly, lots of my code broke. You don't actually want "is 
> this object _equal_ (or not equal) to None", you want "is this object None", 
> as None is a singleton.

However,  given the context of the original question, Sebastian's code
doesn't read like *that* kind of None comparison:

> > > > type '10a80' - that is, an array of 10 80 char 'strings' :
> > > > >>> q.Mrc.hdr = q.Mrc.hdrArray[0].field
> > > > >>> q.Mrc.hdr('title') != None

q.Mrc.hdr('title') is pretty clearly a character array, ergo, it's not
None.  What did you want it to do Sebastian?


More information about the Numpy-discussion mailing list