Skip to main content
Stack Overflow
  1. About
  2. For Teams

Timeline for answer to exec() python2 script from python3 by daphtdazz

Current License: CC BY-SA 3.0

Post Revisions

4 events
when toggle format what by license comment
Mar 9, 2017 at 16:01 comment added daphtdazz Sorry, I should have read a bit more carefully. I've updated my answer to show how to transfer data between the two using json. You may find this an easier thing to do than converting your python2 script to python3 – you could even write a small wrapping python2 script that uses the old exec mechanism to get the result and then send it over to python 3 – but I think those are your only real options.
Mar 9, 2017 at 15:59 history edited daphtdazz CC BY-SA 3.0
Modify the subprocess example so that I show how to use json to to move data across
Mar 9, 2017 at 15:35 comment added sudo_coffee The issue with using os.system to execute as @Benjamin and you(@daphtdazz) mention is parameters from the py3 script are used for execution of py2, then objects saved from py2 are called within modules of the py3 script. An example error returned states TypeError: 'module' object is not subscriptable. The py3 script is modified of an original py2 script (using py3 for interaction with new modules frm imports). This process was originally done using execfile('py2script.py') and all I've described was permissable.
Mar 9, 2017 at 0:10 history answered daphtdazz CC BY-SA 3.0

AltStyle によって変換されたページ (->オリジナル) /