Thanks for the responses, folks.
Robert, thanks for helping me come to terms with the situation, for
pointing out the perils of comparing NaNs, and particularly for the "not
isinstance(x, bool)" idea - some variant of this or attribute checking
as you suggest sounds like what we'll use.
Daniel
On Wed, Mar 23, 2011 at 10:29 AM, Jonathan Hartley wrote:
> Hey people,
>
> I'm writing an application in which we evaluate user-supplied Python
> expressions.
>
> Sometimes, we want to do an equality test on the result of the evaluation,
> eg:
>
> result = eval(...)
> if result == float('
On Wed, Mar 23, 2011 at 09:29, Jonathan Hartley wrote:
> Hey people,
>
> I'm writing an application in which we evaluate user-supplied Python
> expressions.
>
> Sometimes, we want to do an equality test on the result of the evaluation,
> eg:
>
> result = eval(...)
> if result == float('nan
Hey people,
I'm writing an application in which we evaluate user-supplied Python
expressions.
Sometimes, we want to do an equality test on the result of the
evaluation, eg:
result = eval(...)
if result == float('nan'):
...
If the result is a numpy array, then this raises a