DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Python (http://www.daniweb.com/forums/forum114.html)
-   -   Code Snippet: using 2to3 (http://www.daniweb.com/forums/thread217334.html)

leegeorg07 Apr 17th, 2009 4:07 am
using 2to3
 
this is code that thanks to vegaseat helped me convert my programs into python30

  1. # run_2to3_convert.py
  2. #
  3. # convert a Python25 code file to a Python30 code file
  4. # generates a backup file and overwrites the original
  5. # file with the converted file
  6. #
  7. # it is best to put this file into a special directory
  8. # together with the Python25 file you want to convert
  9. #
  10. # run this program with Python30
  11.  
  12. import subprocess
  13.  
  14. # the Python2x code file you want to convert ...
  15. python2x_scriptfile = "TryExcept1.py"
  16.  
  17. subprocess.call([r"C:\Python30\Python.exe",
  18. r"C:\Python30\Tools\Scripts\2to3.py",
  19. "-w",
  20. python2x_scriptfile])
  21.  
  22. print('props to vegaseat for showing me this')
  23. input()

All times are GMT -4. The time now is 3:42 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC