Skip to content

Instantly share code, notes, and snippets.

@xuru
Created April 26, 2013 15:32
Show Gist options
  • Select an option

  • Save xuru/5468157 to your computer and use it in GitHub Desktop.

Select an option

Save xuru/5468157 to your computer and use it in GitHub Desktop.
Version checking in python
import sys
vers = sys.version_info
...
if vers[0] is 2 and vers[1] is 4:
f = open('file.txt', 'r')
try:
# do stuff with f
finally:
f.close()
else:
with open('file.txt', 'r') as f:
# do stuff with f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment