I am using OpenCV, and I want to see what the "rectangle" function is. I can use the dir(module) function, to get at the function definition, and name, but I don't know how to view the actual function. I am Using Linux (Ubuntu 16.04), and I'm wondering if the libraries are in "/usr/local/" or some other place. The OpenCV cv2 python library is just an example, I want to know how to view any function of a library, imported into python.
There are multiple ways :
If you want to get the source code on runtime you can use inspect.getsourcelines(object)
(see https://docs.python.org/3/library/inspect.html#inspect.getsourcelines)
If you want to find where the module is you can simply print(module.__file__)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments