cmd all commands method?

Michele Simionato michele.simionato at gmail.com
Sun Feb 18 03:17:41 EST 2007


On Feb 17, 11:44 pm, Bjoern Schliessmann <usenet-
mail-0306.20.chr0n... at spamgourmet.com> wrote:
> placid wrote:
> > if i want to treat every cmdloop prompt entry as a potential
> > command then i need to overwrite the default() method ?
>
> Excuse me, what's a cmdloop prompt? What's the "default() method"?
>
> > What i want to achieve is to be able to support global variable
> > creation for example;
>
> > res = sum 1 2
>
> > this would create a variable res with the result of the method
> > do_sum() ?
>
> > then would i be able to run;
>
> > sum a  5
>
> > this would return 8 or an error saying that res is not defined
>
> Are you sure you're talking about Python here?


Yes, he is talking about the cmd module: http://docs.python.org/dev/lib/Cmd-objects.html.
However that module was never intended as a real interpreter, so
defining variables
as the OP wants would require some work.

 Michele Simionato




More information about the Python-list mailing list