[Numpy-discussion] Syntax equivalent for np.array()

Keith Goodman kwgoodman@gmail....
Wed Feb 10 10:33:11 CST 2010


On Wed, Feb 10, 2010 at 8:24 AM, Gökhan Sever <gokhansever@gmail.com> wrote:

> Self-correction:
>
> It works correctly in IPython-dev as well.
>
> And further in Python 2.6.2:
>
>>>> p = ()
>>>> p
> ()
>>>> type(p)
> <type 'tuple'>
>>>> type((a*b))
> <type 'numpy.ndarray'>
>
> ( ) doesn't only works as a tuple operator. It also has its original
> parenthesis functionality :)

I think this is the rule: When empty it is a tuple; when containing
one item it is parentheses unless there is a comma.

>> p = (9)
>> type(p)
   <type 'int'>
>> p = (9,)
>> type(p)
   <type 'tuple'>


More information about the NumPy-Discussion mailing list