From: Christian J. <chr...@gm...> - 2006-07-19 10:11:27
|
Hi there, I would like to know what you think is the best way to recognize - right at the beginning of a script -, whether the code is run by Jython or pure Python interpreter, because I will get ImportError when Python sees the "import java" lines etc. (also if the script is part of a package and another module is imported) Right now I am wrapping into a try ... except ImportError statement, but that's not an ideal way to solve this problem. What I need is a serious information source, for example from some sys attribute, that gives me a string containing the word "Jython" or something like that. One possibility I also found, was to check for sys.platform which gives back "Java..." when working with the Jython core. For example one could test like this: if 'Java' in sys.platform: # import of java api classes goes here But I don't know, if that would be reliable. How do you handle this type of problem? Thanks for any information. -- Best Regards Christian Junker |