Preprocessing of input for the interactive interpreter?

S

Stefan Salewski

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:

Format send to interpreter after preprocessing:


Best regards

Stefan Salewski
 
L

Larry Bates

Stefan said:
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:


Format send to interpreter after preprocessing:



Best regards

Stefan Salewski

I'm no expert, but I'll bet that pyparsing module will be the answer to your
question.

-Larry Bates
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top