Preprocessing of input for the interactive interpreter?

Stefan Salewski mail at ssalewski.de
Wed Dec 19 11:00:08 EST 2007


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




More information about the Python-list mailing list