Last active
May 17, 2017 16:26
-
-
Save charnley/d16bd891dded5e7279f577289fa1c518 to your computer and use it in GitHub Desktop.
python 2/3 range
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
| from builtins import range | |
| print(type(range(0))) |
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
| if type(range(0)) == "list": | |
| range = xrange | |
| print(type(range(0))) |
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
| try: | |
| range = xrange | |
| except NameError: | |
| pass | |
| print(type(range(0))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment