On 03Jan2017 00:14, Dennis Lee Bieber <wlfr...@ix.netcom.com> wrote:
On Tue, 3 Jan 2017 11:33:15 +1100, Cameron Simpson <c...@zip.com.au>
declaimed the following:
I'm using cmd.Cmd to write a little FTP-like command line to interface to a
storage system of mine and encountering weird behaviour. When I enter a command
the next prompt appears _before_ the associated operation runs, or so it
appears.
<SNIP>
Has anyone seen this kind of thing before?
Haven't used the module but there is something I find intriguing in the
help system
-=-=-=-=-
Cmd.precmd(line)
Hook method executed just before the command line is interpreted, but
after the input prompt is generated and issued.
-=-=-=-=-
"... AFTER the input prompt is ... issued"
I don't know, but that sure sounds to me like the cmd object tends to
process one line behind... Though that behavior is not shown in the turtle
example in the help system.
Hmm. Interesting. I had read that text to imply (based on what I imagined
_should_ happen) that the flow of control went:
cmdloop:
issue prompt>
line=input() # or readline
line=precmd(line)
stop=onecmd(line) # which calls do_blah...
stop=postcmd(stop,line)
if stop:
break
but your reading of it suggests that this is possible:
issue prompt>
cmdloop:
line=input() # or readline
issue prompt>
line=precmd(line)
stop=onecmd(line) # which calls do_blah...
stop=postcmd(stop,line)
if stop:
break
The text for Cmd.cmdloop starts with this:
Repeatedly issue a prompt, accept input, parse an initial prefix off the
received input, and dispatch to action methods, passing them the remainder of
the line as argument.
which argues for the former, and was what I naively expected.
I guess I'd better dig out the source; I dislike going that far, not merely out
of laziness, but also because the source is not the spec.
Thanks for the suggestion,
Cameron Simpson <c...@zip.com.au>
--
https://mail.python.org/mailman/listinfo/python-list