[SciPy-user] Interactive handling in scipy

Travis E. Oliphant oliphant at ee.byu.edu
Thu Aug 21 16:48:34 EDT 2003


Nils Wagner wrote:
> Dear experts,
> 
> Let us assume, that we have a vector say a with n elements.
> The user should specify a certain element out of this array.
> How can I realize this task in scipy.?
> 
> for i in arange(0,n):
> 
>    print i, a[i]
> 
> print 'Choose a numer 0 <= i <n'
> 
> User input >> j
> 

Python handles this most easily using raw_input.

 >>> info(raw_input)
raw_input([prompt]) -> string

Read a string from standard input.  The trailing newline is stripped.
If the user hits EOF (Unix: Ctl-D, Windows: Ctl-Z+Return), raise EOFError.
On Unix, GNU readline is used if enabled.  The prompt string, if given,
is printed without a trailing newline before reading.



If you want to get real fancy you can play with Python's tty module and 
do all kinds of crazy things.

 >>> help(tty)

for more information.

-Travis O.








More information about the SciPy-User mailing list