[Tutor] input()

Ewald Ertl ewald.ertl at hartter.com
Fri Apr 29 15:17:12 CEST 2005


Hi!

I don't have a Mac and so I don't know Macpython. 

on Fri, 29 Apr 2005 07:55:20 -0500  Servando Garcia <servando at mac.com> wrote :
---------------------------------------------------------------------------------------------

Servando Garcia > Hello and  thanks in advance.
Servando Garcia > 	I am trying to prompt the user for some input. I need three values 
Servando Garcia > from the user so,I used input() like so;
Servando Garcia > Matrix = input("Matrix=")
Servando Garcia > error=input("error=")
Servando Garcia > alpha= input("alpha=")
Servando Garcia >   using  Macpython it works fine but when I use a terminal all I get is 
Servando Garcia > a blank line. When I try to enter at the command line I get this
Servando Garcia > Matrix=error=alpha=
Here on my sun i get the following:

>>> a=input("hello=")
hello=5+6
>>> a
11


When calling help on input the result is the following:

>>> help(input)
Help on built-in function input:

input(...)
    input([prompt]) -> value
    
    Equivalent to eval(raw_input(prompt)).


So the inputvalue is evaluated in python. 

Using raw_input() gives back the entered value: 

>>> a=raw_input("hello=")
hello=myInput
>>> a
'myInput'

Perhaps this work's also on a Mac



Servando Garcia > Also I need to redirect any output from the program into another file, 
Servando Garcia > which is why I used the terminal in the first place. So, I guess I have 
Servando Garcia > two problems

On a UNIX-Shell two programms are connected via the "|" - Pipe. 
The first one writes to stdout ( sys.stdout or print ) and the second 
reads from stdin

Servando Garcia > 	1. How do I redirect output using Macpython?
Servando Garcia > 	2. How do I use input() while using a terminal?
Servando Garcia > 
Servando Garcia > _______________________________________________
Servando Garcia > Tutor maillist  -  Tutor at python.org
Servando Garcia > http://mail.python.org/mailman/listinfo/tutor
Servando Garcia > 


------------------- end ----------------------
HTH 

Ewald 



More information about the Tutor mailing list