Python Forum

Full Version: Python version compatability
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Can we make a python code compatable with python version 2.7 and 3.3.right now my code is in 3.3
look at six package: https://pypi.org/project/six/
It can be installed with pip
pip install six
Depending on your code, there may not be much to fix. Often it's just a question of importing division and/or print_function from __future__, and maybe renaming raw_input as input if possible.
(Nov-28-2018, 07:12 PM)ichabod801 Wrote: [ -> ]Depending on your code, there may not be much to fix. Often it's just a question of importing division and/or print_function from __future__, and maybe renaming raw_input as input if possible.

This is fine . But i have queries regarding the following points:
1.in python 3.3 i have used decode(utf-8).will this cause a problem. If so how can i solve it using six library
2.while running my python code in linux env,2.7,i got a error saying “global name windowsError not defined”.the same doesnt happen for 3.3.how do i solve this
while running my python code in linux env,2.7,i got a error saying “global name windowsError not defined”.the same doesnt happen for 3.3.how do i solve this
You could define your variables before using them. That'd solve the issue.