2

I give the following example to illustrate my question:

import numpy as np
var1 = np.random.rand(3,4)
[e for e in dir(var1) if not e.startwith("__")]

We can see var1 has the following attributes:

['T', 'all', 'any', 'argmax', 'argmin', 'argpartition', 'argsort', 'astype', 'base', 'byteswap', 'choose', 'clip', 'compress', 'conj', 'conjugate', 'copy', 'ctypes', 'cumprod', 'cumsum', 'data', 'diagonal', 'dot', 'dtype', 'dump', 'dumps', 'fill', 'flags', 'flat', 'flatten', 'getfield', 'imag', 'item', 'itemset', 'itemsize', 'max', 'mean', 'min', 'nbytes', 'ndim', 'newbyteorder', 'nonzero', 'partition', 'prod', 'ptp', 'put', 'ravel', 'real', 'repeat', 'reshape', 'resize', 'round', 'searchsorted', 'setfield', 'setflags', 'shape', 'size', 'sort', 'squeeze', 'std', 'strides', 'sum', 'swapaxes', 'take', 'tobytes', 'tofile', 'tolist', 'tostring', 'trace', 'transpose', 'var', 'view']

If I check the shape property, I will call it in this way:

var1.shape

However, when I call min property, I will call it in this way:

var1.min()

My question is how I can know the attribute is a variable, a function or an object (in this case I will use *var1.obj to print the contents). Thanks.

feelfree
  • 11,175
  • 20
  • 96
  • 167

0 Answers0