About IDLE?
Fredrik Lundh
fredrik at pythonware.com
Thu Mar 9 13:46:20 EST 2006
"Dr. Pastor" wrote:
> Installed Python 2.4.2 on Windows XP.
> Activated IDLE.
> Loaded the following into the Edit window:
> ---
> # dates are easily constructed and formatted (Tutorial 10.8)
>
> from datetime import date
> now = date.today()
> now
>
> now.strftime("%m-%d-%y. %d %b %Y is a %A on the %d day of %B.")
>
> # dates support calendar arithmetic
>
> birthday = date(1985, 12, 1)
> age = now - birthday
> age.days
> ---
> When I select Run Module in the Edit window, I got only
> two >>> after the RESTART line.
> I expected to see the output of several commands!
> Typing in age.days do produce the number of days.
>
> Why I do not get any output?
while the interactive console echoes the result back if you type in an
arbitrary expression, the interpreter doesn't do that if you run things in
a script.
to print stuff from a script, use the "print" statement.
print now
print now.strftime(...)
...
print age.days
your favourite tutorial (hopefully) contains more information about the
interactive mode, and how it differs from code in scripts or modules.
hope this helps!
</F>
More information about the Python-list
mailing list