Preprocessing of input for the interactive interpreter?
Larry Bates
larry.bates at websafe.com
Wed Dec 19 12:10:16 EST 2007
Stefan Salewski wrote:
> Hello,
>
> I just start learning Python (ordered "Dive into Python" a week ago).
>
> In the past I have used the Python interactive interpreter for some
> calculations instead of Linux command line tools like "bc" or "calc".
>
> I wonder if it is possible to do a pre-processing of command strings in
> the interactive interpreter. (Not that I really need it, and currently my
> Python skills are far away to manage this hack. But I am curious -- did
> some Google search yesterday, but did not find an answer. Yes, an extended
> interpreter called IPython exists -- this one seems to have this
> functionality, and I may use this one later.)
>
> It is possible to convert input in this form (input hook?):
>
> My custom input format:
>
>>>> b := 10a + 0,1
>
> Format send to interpreter after preprocessing:
>
>>>> b = 10*a + 0.1
>
>
> Best regards
>
> Stefan Salewski
>
I'm no expert, but I'll bet that pyparsing module will be the answer to your
question.
-Larry Bates
More information about the Python-list
mailing list