Skip to content

Instantly share code, notes, and snippets.

@elee
Created June 8, 2011 18:59
Show Gist options
  • Save elee/1015085 to your computer and use it in GitHub Desktop.
Save elee/1015085 to your computer and use it in GitHub Desktop.
if os.path.exists('/private/tmp/corehist.txt'):
with open('/private/tmp/corehist.txt', 'r') as f:
int_from_file = int(f.readline())
if my_int != int_from_file:
f.seek(0)
f.writeline(new_int_value)
else:
with open('/private/tmp/corehist.txt', 'w+') as f:
f.write(42)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment