find location python code example
Example 1: how to find where python is located
>>> import os
>>> import sys
>>> os.path.dirname(sys.executable)
'C:\\Python25'
Example 2: find python path windows
>>> import os
>>> import sys
>>> os.path.dirname(sys.executable)
'C:\\Python25'
Example 3: find location of a class in python
import inspect
inspect.getfile(C.__class__)
Example 4: find location of a class in python
import sys, os
os.path.abspath(sys.modules[LocationArtifact.__module__].__file__)