Search code examples
pythondjangojython

Can I detect if my code is running on cPython or Jython?


I'm working on a small django project that will be deployed in a servlet container later. But development is much faster if I work with cPython instead of Jython. So what I want to do is test if my code is running on cPython or Jython in my settiings.py so I can tell it to use the appropriate db driver (postgresql_psycopg2 or doj.backends.zxjdbc.postgresql). Is there a simple way to do this?


Solution

  • if you're running Jython

    import platform
    platform.system()  
    

    return 'Java'
    here has some discussion, hope this helps.