import sys
if sys.version_info[0] == 3:
python-3-code
else:
python-2-code
#!/usr/bin/env python
def main():
hsh = {'a':1}
for k in hsh.keys():
print "k", k
try:
a = 1/0
except Exception as e:
print( repr( e))
return
if __name__ == "__main__":
main()
--- 2to3:
def main():
hsh = {'a':1}
- for k in hsh.keys():
- print "k", k
+ for k in list(hsh.keys()):
+ print("k", k)
try:
a = 1/0
except Exception as e:
- print( repr( e))
+ print(( repr( e)))
return