[Numpy-discussion] comparing string array with None raises ValueError
haase at msg.ucsf.edu
Thu Jun 24 12:14:31 CDT 2004
On Thursday 24 June 2004 11:46 am, Todd Miller wrote:
> On Thu, 2004-06-24 at 13:46, Sebastian Haase wrote:
> > On Thursday 24 June 2004 10:31 am, Todd Miller wrote:
> > > On Thu, 2004-06-24 at 13:06, Sebastian Haase wrote:
> > > > Hi,
> > > > I'm not sure if this is fixed already in CVS but here it goes:
> > > > I'm working with record arrays, and trying to access a field with
> > > >
> > > > type '10a80' - that is, an array of 10 80 char 'strings' :
> > > > >>> q.Mrc.hdr = q.Mrc.hdrArray.field
> > > > >>> q.Mrc.hdr('title') != None
> > >
> > > Shouldn't this be:
> > >
> > > q.Mrc.hdr('title') != ""
> > (in my first reply, I forgot to point out that q.Mrc.hdr('title') is an
> > ARRAY of strings ! )
> > No, I understand that this makes more sense, but I have some "display
> > hook"-code that compares everything with None...
> > In general it must be OK to compare anything with None, right ?
> > (BTW, I get the same error with == and !=)
> OK, I see your point. I talked it over with Perry and he made a
> reasonable case for allowing comparisons with None (or any object).
> Perry argued that since None is a common default parameter value, it
> might simplify code to not have to add logic to handle that case.
> If no one objects, I'll change numarray.strings so that comparison of a
> string array with any object not convertible to a string array results
> in an array of False values.
> Any objections?
Just my feeling is, that a single None would do it ...
More information about the Numpy-discussion