[SciPy-user] truth testing new numpy arrays
Paul.Ray at nrl.navy.mil
Tue Jan 31 13:10:03 CST 2006
On Jan 31, 2006, at 10:43 AM, Travis Oliphant wrote:
> I typically use None for optional array arguments.
> But, you could do what your doing and test
> if any(myvect):
> <do something>
> <do something else>
> But, I think the None test is less prone to error.
Assuming you use None for unset optional arguments, how do you do
doesn't work because it is ambiguous if myvect isn't none.
doesn't work because None doesn't have an any() method
So, do you use:
if myvect is not None:
Dr. Paul S. Ray E-mail: Paul.Ray at nrl.navy.mil
Naval Research Laboratory WWW : http://xweb.nrl.navy.mil/
Code 7655 Phone : (202) 404-1619
Washington, DC 20375 AIM : NRLPSR
More information about the SciPy-user