Convert your Python 2.x source code into valid Python 3.x code.
yarn global add py23
npm install -g py23
py23 --path ./
// recursively convert all python 2.x source code files into python 3 valid code
py23 --path ./app.py
// converts all code in app.py file
Converts the print statement to the print() function.
Renames os.getcwdu() to os.getcwd().
Converts raw_input() to input().
Converts raise E, V to raise E(V)
Changes dict.has_key(key) to key indict.
Converts except X, T to except X as T.
Python 2.x (From) | Python 3.x (To) |
---|---|
failUnlessEqual(a, b) | assertEqual(a, b) |
assertEquals(a, b) | assertEqual(a, b) |
failIfEqual(a, b) | assertNotEqual(a, b) |
assertNotEquals(a, b) | assertNotEqual(a, b) |
failUnless(a) | assertTrue(a) |
assert_(a) | assertTrue(a) |
failIf(a) | assertFalse(a) |
failUnlessRaises(exc, cal) | assertRaises(exc, cal) |
failUnlessAlmostEqual(a, b) | assertAlmostEqual(a, b) |
assertAlmostEquals(a, b) | assertAlmostEqual(a, b) |
failIfAlmostEqual(a, b) | assertNotAlmostEqual(a, b) |
assertNotAlmostEquals(a, b) | assertNotAlmostEqual(a, b) |