There are four public array attributes; however, they are only available
in Python 2.2 or later. There are array methods that may be used instead. The
attributes are shape, flat, real, and imaginary.
shape
Accessing the shape attribute is equivalent to calling the
getshape method; it returns the shape tuple. Assigning a value to
the shape attribute is equivalent to calling the setshape method.
Accessing the flat attribute of an array returns the flattened, or
raveled version of that array, without having to do a function
call. This is equivalent to calling the getflat method. The
returned array has the same number of elements as the input array, but it is
of rank-1. One cannot set the flat attribute of an array, but one can use
the indexing and slicing notations to modify the contents of the array:
These attributes exist only for complex arrays. They return respectively
arrays filled with the real and imaginary parts of the elements. The
equivalent methods for getting and setting these values are
getreal, setreal, getimag, and setimag.
getimaginary and setimaginary are synonyms for
getimag and setimag respectively, and .imag is a
synonym for .imaginary. The arrays returned are not contiguous
(except for arrays of length 1, which are always contiguous).
The attributes real, imag, and imaginary are
modifiable: