Use size in Python
Question: I created a ndarray array in python

    
    
    temp = np.array([1, 2, 3, 4])
    

To measure the length of this array, I can use

    
    
    temp.size
    

or

    
    
    np.size(temp)
    

both return 4. But I'm wondering what's the difference between the two
expressions? Also, to get the lena image, I need to write

    
    
    >>> import scipy.misc
    >>> lena = scipy.misc.lena()
    

I'm wondering why there's a bracket pair after lena? Isn't lena a matrix?
Something with () is like a function. I understand lena() is a function takes
no inputs and returns a ndarray. I just feel like it's tedious to write this
way.

In Matlab, it's quite clear to distinguish between a constant and a function.
Function is defined and called with (), but constant (or pre-stored) can be
called directly, e.g., "blobs.png"


Answer: `np.size(temp)` is a little more general than `temp.size`. At first glance,
they appear to do the same thing:

    
    
    >>> x = np.array([[1,2,3],[4,5,6]])
    >>> x.size
    6
    >>> np.size(x)
    6
    

This is true when you don't supply any additional arguments to `np.size`. But
if you look at the
[documentation](http://docs.scipy.org/doc/numpy/reference/generated/numpy.ma.size.html#numpy.ma.size)
for `np.size`, you'll see that it accepts an additional `axis` parameter,
which gives the size along the corresponding axis:

    
    
    >>> np.size(x, 0)
    2
    >>> np.size(x, 1)
    3
    

As far as your second question, `scipy.misc.lena` _is_ a function as you point
out. It is not a matrix. It is a function returning a matrix. The function
(presumably) loads the data on the fly so that it isn't placed in memory
whenever you import the `scipy.misc` module. This is a _good_ thing, and
actually not all that different than matlab.

