3 ms·
Okay, so how should the following loop be rewritten: while self.keep_going: s = input('> ').lstrip() if s == '': continue
by Joker_vD 5y ago
Okay, so how should the following loop be rewritten:
while self.keep_going:
s = input('> ').lstrip()
if s == '':
continue
cmd = self.parse_cmd(s)
# The "quit" commands sets self.keep_going to False, oh the horrors
# of the global mutable state
cmd()
? Should it be:
for cmd in self.stream_of_commands():
cmd()
But stream_of_commands() will still have a loop inside it, wouldn't it? Because that's how you write generators?