How to check in script if Python or Jython is used

Laura Creighton lac at openend.se
Sun Jun 21 05:22:56 EDT 2015


In a message of Sun, 21 Jun 2015 10:12:06 +0200, Cecil Westerhof writes:
>I installed Jython and will start playing with it. There probably will
>be differences between Python and Jython. Is there a way to determine
>if a script is run by Python or Jython? Then different execution paths
>could be taken. With sys.version(_info) you do not get this
>information.
>
>-- 
>Cecil Westerhof
>Senior Software Engineer
>LinkedIn: http://www.linkedin.com/in/cecilwesterhof
>-- 
>https://mail.python.org/mailman/listinfo/python-list

import platform
platform.python_implementation()

If your jython is old (pre 2.6) you will not have this.

Then try
platform.system()
which will give you 'Java'

Laura





More information about the Python-list mailing list