What are some strategies to write python code that works in CPython, Jython and IronPython

前端 未结 6 2002
忘了有多久
忘了有多久 2021-02-02 14:55

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 environ

6条回答
  •  天命终不由人
    2021-02-02 15:05

    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.

提交回复
热议问题