mdirty added to updates

using walrus operator in examples
This commit is contained in:
onyx-and-iris
2022-06-27 18:42:50 +01:00
parent 771bc223ac
commit 51390236c3
3 changed files with 12 additions and 18 deletions

View File

@@ -63,16 +63,12 @@ def main(cmds=None):
if res:
print(res)
else:
try:
while True:
cmd = input("please enter command (Return to exit)\n")
if not cmd:
break
res = parser.parse((cmd,))
if res:
print(res)
except KeyboardInterrupt as e:
SystemExit(e)
while cmd := input("Please enter command (Press <Enter> to exit)\n"):
if not cmd:
break
res = parser.parse((cmd,))
if res:
print(res)
if __name__ == "__main__":
@@ -99,4 +95,4 @@ if __name__ == "__main__":
)
# pass cmds to parse cmds, otherwise simply run main() to test stdin parsing
main(cmds)
main()

View File

@@ -14,13 +14,9 @@ def main():
obs = Observer(vm)
vm.subject.add(obs)
try:
while True:
cmd = input("Press Return to exit\n")
if not cmd:
break
except KeyboardInterrupt as e:
SystemExit(e)
while cmd := input("Press <Enter> to exit\n"):
if not cmd:
break
if __name__ == "__main__":