1) Big circle sign echoes the small round thing they hold.
2) The person’s small, proud pose feels sweet.
3) Warm light and the huge door make them look tiny and charming.
1) Big circle sign echoes the small round thing they hold.
2) The person’s small, proud pose feels sweet.
3) Warm light and the huge door make them look tiny and charming.
cmd=sys.argv[1]
if cmd=='list': list_t(t)
elif cmd=='add': add(t,' '.join(sys.argv[2:]))
elif cmd=='done': done(t,int(sys.argv[2]))
elif cmd=='rm': rm(t,int(sys.argv[2]))
else: print('unknown cmd')
if __name__=='__main__': main()
cmd=sys.argv[1]
if cmd=='list': list_t(t)
elif cmd=='add': add(t,' '.join(sys.argv[2:]))
elif cmd=='done': done(t,int(sys.argv[2]))
elif cmd=='rm': rm(t,int(sys.argv[2]))
else: print('unknown cmd')
if __name__=='__main__': main()
def done(t,i):
t[i-1]['done']=True
save(t)
Part 4/4 — CLI start:
import sys
def main():
t=load()
if len(sys.argv)<2:
print('usage: todo.py list|add "text"|done N|rm N')
def done(t,i):
t[i-1]['done']=True
save(t)
Part 4/4 — CLI start:
import sys
def main():
t=load()
if len(sys.argv)<2:
print('usage: todo.py list|add "text"|done N|rm N')
def add(t,text):
t.append({'text':text,'done':False}); save(t)
def list_t(t):
for i,it in enumerate(t,1): print(f"{i}. [{'x' if it['done'] else ' '}] {it['text']}")
def rm(t,i):
t.pop(i-1); save(t)
def add(t,text):
t.append({'text':text,'done':False}); save(t)
def list_t(t):
for i,it in enumerate(t,1): print(f"{i}. [{'x' if it['done'] else ' '}] {it['text']}")
def rm(t,i):
t.pop(i-1); save(t)
#!/usr/bin/env python3
import sys,os,json
FILE='todos.txt'
def load():
if not os.path.exists(FILE): return []
with open(FILE,'r') as f:
return json.load(f)
def save(t):
with open(FILE,'w') as f:
json.dump(t,f,indent=2)
#!/usr/bin/env python3
import sys,os,json
FILE='todos.txt'
def load():
if not os.path.exists(FILE): return []
with open(FILE,'r') as f:
return json.load(f)
def save(t):
with open(FILE,'w') as f:
json.dump(t,f,indent=2)