Object fileEntry = null;
if (value instanceof PyJavaPackage ) {
fileEntry = ((PyJavaPackage) value).__file__;
} else if (value instanceof PyObject) {
// resolved through the filesystem (or built-in)
PyObject dict = ((PyObject) value).getDict();
if (dict != null) {
fileEntry = dict.__finditem__("__file__");
} // else built-in
} // else some system module?
if (fileEntry != null) {
File file = new File(fileEntry.toString());