def obj2sctype(rep, default=None):
try:<EOL><INDENT>if issubclass(rep, generic):<EOL><INDENT>return rep<EOL><DEDENT><DEDENT>except TypeError:<EOL><INDENT>pass<EOL><DEDENT>if isinstance(rep, dtype):<EOL><INDENT>return rep.type<EOL><DEDENT>if isinstance(rep, type):<EOL><INDENT>return _python_type(rep)<EOL><DEDENT>if isinstance(rep, ndarray):<EOL><INDENT>return rep.dtype.type<EOL><DEDENT>try:<EOL><INDENT>res = dtype(rep)<EOL><DEDENT>except:<EOL><INDENT>return default<EOL><DEDENT>return res.type<EOL>
Return the scalar dtype or NumPy equivalent of Python type of an object.

Parameters
----------
rep : any
    The object of which the type is returned.
default : any, optional
    If given, this is returned for objects whose types can not be
    determined. If not given, None is returned for those objects.

Returns
-------
dtype : dtype or Python type
    The data type of `rep`.

See Also
--------
sctype2char, issctype, issubsctype, issubdtype, maximum_sctype

Examples
--------
>>> np.obj2sctype(np.int32)
<type 'numpy.int32'>
>>> np.obj2sctype(np.array([1., 2.]))
<type 'numpy.float64'>
>>> np.obj2sctype(np.array([1.j]))
<type 'numpy.complex128'>

>>> np.obj2sctype(dict)
<type 'numpy.object_'>
>>> np.obj2sctype('string')
<type 'numpy.string_'>

>>> np.obj2sctype(1, default=list)
<type 'list'>