Which Python implementation am I using?

Laura Creighton lac at openend.se
Sat Aug 8 01:03:19 CEST 2015


In a message of Sat, 08 Aug 2015 03:27:04 +1000, "Steven D'Aprano" writes:
>
>    def jython():
>        t = platform.java_ver()
>        return (t and t[0]) or ('java' in sys.platform.lower())

Around here if we cannot find platform.python_implemention()
we just look for sys.platform.startswith('java')

Are there any cases where you need platform.java_ver() ?

I don't know about IronPython

>How about PyPy, Stackless, or others?

PyPy has platform.python_implementation these days as well.  If you
cannot find it, look for '__pypy__' in sys.builtin_module_names

For detecting Stackless my PYTHONSTARTUP just tries to import stackless.

Detecting Cygwin may be important for you.  It's a real mess.
platform.system usually gives you stuff like: CYGWIN_NT-5.1
but, alas, sometimes it just gives you 'Windows'.
os.name sometimes gives you 'nt' -- but sometimes it gives you 'posix'.

I've played whack-a-mole with this one for a while, and still don't
like any of our solutions.  And the customer threw out his windows
systems and replaced them with Macs, so the problem now is moot for me.

Laura


More information about the Python-list mailing list