[py-dev] my first post to the list
Michele Simionato
michele.simionato at gmail.com
Thu Apr 28 11:33:10 CEST 2005
On 4/28/05, Armin Rigo <arigo at tunes.org> wrote:
> For the records, as Michele asked me, I've put the greenlet example I gave in
> the lightning talk into the greenlet documentation:
>
> http://codespeak.net/py/current/doc/greenlet.html#example
I think the example could be improved a bit. We have
def process_commands(*args):
while True:
line = ''
while not line.endswith('\n'):
line += read_next_char()
if line == 'quit\n':
print "are you sure?"
if read_next_char() != 'y':
continue # ignore the command
process_command(line)
but the *args are ignored and 'process_command' looks too similar
to process_commands; also the continue line looks strange.
Why not just
def show_entered_commands():
while True:
line = ''
while not line.endswith('\n'):
line += read_next_char()
print line
if line == 'quit\n':
print "are you sure?"
if read_next_char() == 'y':
break
? Anyway, this is a pretty cool example of what you can do with greenlets.
Michele
More information about the Pytest-dev
mailing list