multiline raw input

Fernando Pérez fperez528 at yahoo.com
Fri Mar 15 11:24:11 EST 2002


les ander wrote:

> Hi,
> i have a program that takes input from the command line
> however this input is multi-line and will have a lot of backslashes
> I tried using sys.stdin but it ignores the backslashes.
> i tried with raw_input but that only takes in the first line
> 
> can some suggest a remedy?
> 
> 
> 
> 
> for example:
> i would like to run my program as follows:
> 
>>> myprog.py
> Type in some input (type in '.' to end) :
> \sum_{i=1}^{n} \frac{\sqrt{2}}{\alpha} \infty
> \begin{itemize}
> \item this equation says that
> \end{itemize}
> .

Untested (written in the newsposter :). See if it helps:

print "Type in some input (type in '.' to end) :"
input_list = []
while 1:
  input = raw_input()
  if input == '.': break
  input_list.append(input)

# do whatever you want with input_list...

... Writing some sort of interactive LaTeX prompt here ??


Cheers,

f.



More information about the Python-list mailing list