Skip to content

Instantly share code, notes, and snippets.

@FilipDominec
Created July 11, 2017 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FilipDominec/9491d2ecfe827e7127baf9aba863b340 to your computer and use it in GitHub Desktop.
Save FilipDominec/9491d2ecfe827e7127baf9aba863b340 to your computer and use it in GitHub Desktop.
Little command that returns 01, 02, 03... upon repeated calls. Good for automatic sequential numbering of simulations etc.
#!/usr/bin/python3
try:
with open('num.txt') as ff:
num = int(ff.read())+1
except FileNotFoundError:
num=1
numstr = '{:02d}'.format(num)
print(numstr)
with open('num.txt', 'w') as ff:
ff.write(numstr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment