Jump to content

[Python] Code Translator 2 to 3


Recommended Posts

  • Moderator

M2 Download Center

Download Here ( Internal )

Download Here ( GitHub )

Python-Code-Translator-2-to-3

Is a Python program that reads Python 2.x source code and applies a series of fixers to transform it into valid Python 3.x code that works on all versions (py2.x - py3.x).

The standard library contains a rich set of fixers that will handle almost all code. A flexible and generic library, so it is possible to write your own fixers based on your purposes.

Warning: This tool purpose wasn't for doing the transition to python3, is just for the IDE purpose.

INSTALLATION
USING
  • Add your .py scripts to the modules folder.
  • Run main.bat
  • Take the output files and move them into your application.
FIXERS
print
  • Converts the print statement to the print() function.
  • Matching multiple formats, comments, and more.
Exception handling
  • Convert except to except BaseException, since BaseException is the base class for all built-in exceptions.
  • Converts except X, T to except X as T.
xrange
  • Renames xrange() to range() and wraps existing range() calls with list.
has_key
  • Changed dict.has_key(key) to dict..contains__(key)
dict
  • Fixes dictionary iteration methods. dict.iteritems() is converted to dict.items(), dict.iterkeys() to dict.keys(), and dict.itervalues() to dict.values(). Similarly, dict.viewitems(), dict.viewkeys() and dict.viewvalues() are converted respectively to dict.items(), dict.keys() and dict.values(). It also wraps existing usages of dict.items(), dict.keys(), and dict.values() in a call to list.
exec - TODO
  • Converts the exec statement to the exec() function.
apply - TODO
  • Removes usage of apply(). For example apply(function, *args, **kwargs) is converted to function(*args, **kwargs).
raise - TODO
  • Converts raise E, V to raise E(V), and raise E, V, T to raise E(V).with_traceback(T). If E is a tuple, the translation will be incorrect because substituting tuples for exceptions has been removed in 3.0.

 

You can use it together with Skeleton of Python modules for IDE, from @Takuma.

 

Download:

Hidden Content

    Give reaction to this post to see the hidden content.

  • Metin2 Dev 10
  • Love 22
  • Good 9
  • Confused 1
Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



Shoutbox

Shoutbox

Chatroom Rules

 

Join our Discord

A request for help = Shoutbox Ban

Be respectful & Respect the rules

 

×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.