How can I tell which python implementation I'm using?

Question:

Python has a few different implementations: CPython, Jython, PyPy, etc. I want to programmatically determine which implementation my code is running on. How can I do that?

To be specific, write a function called get_implementation_name() for me:

impl_name = get_implementation_name()
if impl_name == "CPython":
  print "I can abuse CPython implementation details. (I'm a bad, bad man.)"
elif impl_name == "PyPy":
  print "Can't count on reference-counting garbage collection here..."
else:
  print "I better be careful..."
Asked By: Stuart Berg

||

Answers:

In [50]: import platform    
In [52]: platform.python_implementation()
Out[52]: 'CPython'
Answered By: unutbu

How about platform

it gives you

platform.python_implementation()
Answered By: Jakob Bowyer
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.