[TxMt] Re: Python: Extra Output
Luke Daley
ld at ldaley.com
Mon Sep 21 23:37:26 UTC 2009
On 22/09/2009, at 9:25 AM, Alex Ross wrote:
>> Hi, I am completely new to programming and am trying textmate out
>> based on some reviews I've read. I'm learning python as my first
>> language.
>>
>> My question is this: I am writing basic small programs in python and
>> when I run the program to see if it works, even if it works properly
>> it always finishes the output with the last data that I enter into
>> it.
>>
>> For example, if I enter:
>>
>> n = input("Please enter a whole number: ")
>> fact = 1
>> for factor in range(n, 1, -1):
>> fact = fact * factor
>>
>> print "The factorial of", n, "is", fact
>>
>> When I run the program (with an input of '10'):
>>
>> ' Please enter a whole number: The factorial of 10 is 3628800
>> 10'
>>
>> When I run the program in IDLE I don't get the extra output.
>>
>> Thank you.
>
> TextMate injects code into python so that it may notice when you call
> “input” and show a dialog. Whatever you enter into the dialog will
> then be echoed in the output (this mimics how the terminal behaves,
> when you type a character it is echoed in the terminal). I don't know
> how exactly IDLE is handling this, but if you run your program in
> terminal you'll see what I mean.
Alex,
This is configurable behaviour of interactive input. The
TM_INTERACTIVE_INPUT env var controls this via the presence of “ECHO”
in it's value.
e.g.
TM_INTERACTIVE_INPUT=ALWAYS|ECHO
or
TM_INTERACTIVE_INPUT=ECHO
Do we expose control of this through executor?
More information about the textmate
mailing list