So in an iPython terminal
, if you type a method followed by ??
you will get the source code and its location:
In [1]: import numpy as np
In [2]: np.angle??
Source:
@array_function_dispatch(_angle_dispatcher)
def angle(z, deg=False):
z = asanyarray(z)
if issubclass(z.dtype.type, _nx.complexfloating):
zimag = z.imag
zreal = z.real
else:
zimag = 0
zreal = z
a = arctan2(zimag, zreal)
if deg:
a *= 180/pi
return a
File: ~/Documents/venv_global/lib/python3.8/site-packages/numpy/lib/function_base.py
Type: function
How would I find the location of the source code (+the line number of the method) without entering into iPython
.
PS: (Removed the docstring from the output for readability).
Edit:
I am looking for something like a subcommand that I can run which would give the information without needing to enter the shell. Not sure if it is possible though but it would look something like this:
ipython --source numpy.angle