Having tries to target two of these environments at the same time I can safely say the if you have to use a database etc. you end up having to write unique code for that environment. Have you got a great way to handle this situation?
6 Answers
If you do find you need to write unique code for an environment, use pythons
import mymodule_jython as mymodule
import mymodule_cpython as mymodule
have this stuff in a simple module (''module_importer''?) and write your code like this:
from module_importer import mymodule
This way, all you need to do is alter module_importer.py per platform.
3 Comments
os can be used as an example. It provides OS routines e.g., os.unlink, os.rename, etc depending on what system you're on.@Daren Thomas: I agree, but you should use the platform module to determine which interpreter you're running.
1 Comment
I write code for CPython and IronPython but tip should work for Jython as well.
Basically, I write all the platform specific code in separate modules/packages and then import the appropriate one based on platform I'm running on. (see cdleary's comment above)
This is especially important when it comes to the differences between the SQLite implementations and if you are implementing any GUI code.
Comments
I'm pretty sure you already know this but unfortunately Jython can't load c extension modules.