On 29 May 2012, at 15:42, Nathaniel Smith wrote:

>> I note the fine distinction between np.isscalar( ('hello') ) and 
>> np.isscalar( ('hello'), )...
> 
> NB you mean np.isscalar( ('hello',) ), which creates a single-element
> tuple. A trailing comma attached to a value in Python normally creates
> a tuple, but in a function argument list it is treated as separating
> arguments instead, and a trailing empty argument is ignored. The
> parentheses need to be around the comma to hide it from from the
> argument list parsing rule so that the tuple rule can see it.
> (Probably you know this, but for anyone reading the archives later...)

Correct, sorry for the typo! 
I was actually puzzled by the habit of what seemed to me automatic unpacking of 
the 
simple case ('hello') as compared to ('hello', ); I only now looked up that by 
the Python 
syntax indeed the comma makes the tuple, not the parentheses, the latter only 
becoming necessary to protect the comma as you describe above.
Just stumbled on this as in several cases, numpy's rules for creating arrays 
from tuples 
are slightly different from those for creating arrays from lists. 

Cheers,
                                                Derek

_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to