[SciPy-user] bug or feature
Christian Kristukat
ckkart at hoc.net
Tue Aug 16 09:21:23 EDT 2005
Christian Meesters wrote:
> Hi
>
> I'm using scipy 0.3.2 and run into troubles. To illustrate them just this:
>
> >>> x = None
> >>> if x: print 'hello' #nothing happens here
> ...
> >>> from scipy import *
> >>> a = array(None)
> >>> if a: print 'hello' #will print 'hello', why?
> ...
> hello
> >>> print a
> None
>
> I consider it a nice feature that no exception is raised when None is
> passed to array(), but apparently 'None' in Python is something
> different than 'None' in SciPy - or is it? Should I know about this? How
> should I deal with it? Asking with 'if' does not really work here to
> check whether an object 'really' exists. And using try/except for every
> possible case is not really feasible ...
Calling type() in both cases yields:
<type 'NoneType'>
and
<type 'array'>
so only the first is really None, the second is an array object which contains
'None'. You can check that with
if a is array(None):
print 'None'
In what cases is that behaviour causing problems? Why do you need that kind of
arrays?
Regards, Christian
More information about the SciPy-User
mailing list