python - How to know that the interpreter is Jython or CPython in the code? -


this question has answer here:

is there way detect interpreter executes code jython or cpython?

i have post: jython not catch exceptions. case, if know interpreter jython, can have different code should work.

if jython:     sys.path.insert(0, os.path.dirname(__file__))     utils import * else:     .utils import * 

there official way it! :-) please have at

http://docs.python.org/2/library/platform.html#platform.python_implementation

returns string identifying python implementation. possible return values are: ‘cpython’, ‘ironpython’, ‘jython’, ‘pypy’.

new in version 2.6.

i did not know before.

old answer:

there no standardized interface, can use educated guessing, based on e.g. sys.executable (http://docs.python.org/2/library/sys.html#sys.executable), , sys.version. furthermore, interpreters sure provide features specific them, can make use of.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -