Getting stdin using TextWrangler or BBEdit, but not MacPython (was:
[Pythonmac-SIG] One IDE can find sys._buf,
the other can't. What's going on?)
pecora at anvil.nrl.navy.mil
Thu Mar 3 22:57:50 CET 2005
Bob Ippolito wrote:
> As far as this code goes, you might be able to just get away with it
> if you do:
> # check for MacPython IDE
> if hasattr(sys.stdout, '_buf'):
> sys.stdout._buf = ...
You're right this is a test that would shut off the _buf part of the
code if I were not using MacPython.
> It really depends on what the rest of your code looks like. If it
> does sys.stdout.readline() for example, it's still going to be broken,
> because you can't normally read from stdout. The rawinput() function
> might do what you want everywhere else, though.
I can't seem to get rawinput or raw_input() to work. Ignoring my
previous code. I just want something that can take standard input so,
for instance, when I prompt with
print "Input 2 ints and a float"
The program will wait until I type, say
2 5 5.476 (return)
Then hand back the three numbers either as a string, a list, or
individual int and float types so I can process them with my program.
Sort of like
int i1, i2;
scanf(" %d %d %e", i1, i2, f1);
would do in C using stdin. Or even a gets() which I could then process
to pull out the two ints and a float.
I'm just looking for simple input of numbers and strings. I'd like to
do this from BBEdit rather than MacPython. Anyone out there done this
Naval Research Lab
Washington, DC 20375
email: pecora at anvil.nrl.navy.mil
More information about the Pythonmac-SIG