Fix for issue #236
Merge pull request #2548 from eliangidoni/fix-236

Fix for issue #236 by @eliangidoni
Use Python 2 and 3 dict iteration methods.
Use the Python print function instead of statements.
Python 3 does not have unicode and long types.
Remove the xrange function to support Python 3.
Use the builtin next to support iterators in Python 2 and 3
Change how a code object is retrieved depending on the Python version.