Created
November 12, 2013 22:22
-
-
Save rwhitt2049/7439882 to your computer and use it in GitHub Desktop.
backwards compatibility for python 2/3 dictionary calls
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def iterkeys(d): | |
| """Python 2/3 compatibility function for dict.iterkeys()""" | |
| if __python_version_major >= 3: | |
| return d.keys() | |
| else: | |
| return d.iterkeys() | |
| def itervalues(d): | |
| """Python 2/3 compatibility function for dict.itervalues()""" | |
| if __python_version_major >= 3: | |
| return d.values() | |
| else: | |
| return d.itervalues() | |
| def iteritems(d): | |
| """Python 2/3 compatibility function for dict.iteritems()""" | |
| if __python_version_major >= 3: | |
| return d.items() | |
| else: | |
| return d.iteritems() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment