[TxMt] Re: Python: Extra Output
Alex Ross
tm-alex at rosiba.com
Mon Sep 21 23:25:21 UTC 2009
On Sep 21, 2009, at 2:02 PM, neoethical 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
More information about the textmate
mailing list