[Python-ideas] Yielding from the command line
Martin Teichmann
lkb.teichmann at gmail.com
Thu Sep 11 15:42:43 CEST 2014
Hi List,
I'm currently trying to convince my company that asyncio is a great
thing. After a lot of critique, the newest thing is, people complain:
I cannot test my code on the command line! And indeed they are
right, a simple
a = yield from some_coroutine()
is not possible on the command line, and doesn't make sense.
Wait a minute, really?
Well, it could make sense, in an asyncio-based command line.
I am thinking about a python interpreter whose internal loop is
something like
@coroutine
def commandline():
while True:
cmd = yield from input_async()
code = compile(cmd, "<stdin>", "generator")
yield from exec(code)
A new compile mode would allow to directly, always create a
generator, and exec should be certainly be able to handle this.
I think this would not only make people happy that want to test
code on the command line, but also all those people developing
command line-GUI combinations (IPython comes to mind),
which have to keep several event loops in sync.
Greetings
Martin
More information about the Python-ideas
mailing list