Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > About IDLE?

Reply
Thread Tools

About IDLE?

 
 
Dr. Pastor
Guest
Posts: n/a
 
      03-09-2006
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.

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?
Thanks for any guidance.


 
Reply With Quote
 
 
 
 
Sybren Stuvel
Guest
Posts: n/a
 
      03-09-2006
Dr. Pastor enlightened us with:
> 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!


You never gave it any commands that print output.

I suggest reading the Python tutorial.

Sybren
--
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself?
Frank Zappa
 
Reply With Quote
 
 
 
 
Fredrik Lundh
Guest
Posts: n/a
 
      03-09-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.
>
> 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>



 
Reply With Quote
 
Nick Smallbone
Guest
Posts: n/a
 
      03-09-2006
Sybren Stuvel wrote:
> Dr. Pastor enlightened us with:
> > 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!

>
> You never gave it any commands that print output.
>
> I suggest reading the Python tutorial.
>


To be more specific, when you type in an expression at the Python
prompt, it will evaluate it and then print it (if it doesn't evaluate
to None). In a module it doesn't do that, as then you'd have all sorts
of things printed out modules were imported.

 
Reply With Quote
 
Dr. Pastor
Guest
Posts: n/a
 
      03-09-2006
Any reply?

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.
>
> 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?
> Thanks for any guidance.
>
>

 
Reply With Quote
 
Nick Smallbone
Guest
Posts: n/a
 
      03-10-2006
Dr. Pastor wrote:
> Any reply?
>


ahem. three replies, when i counted:
http://groups.google.com/group/comp....c8455251e616c/

 
Reply With Quote
 
Terry Reedy
Guest
Posts: n/a
 
      03-10-2006

"Dr. Pastor" <(E-Mail Removed)> wrote in message
news:zs_Pf.4292$(E-Mail Removed) nk.net...
> Installed Python 2.4.2 on Windows XP.
> Activated IDLE.
> Loaded the following into the Edit window:


> Why I do not get any output?
> Thanks for any guidance.


When you run code from an edit window, IDLE saves the file to disk and then
*imports* it into the shell window. If you *paste* code into the shell
window (regardless of where from), then it acts like you typed it and you
will get expression results echoed, as you expected.

I got caught be this at first too, since I have run many snippets by
pasting.

Terry Jan Reedy



 
Reply With Quote
 
Dr. Pastor
Guest
Posts: n/a
 
      03-10-2006
Thank you! I can see only your reply.
But indeed google prints three.
The mind boggles.


Nick Smallbone wrote:

> Dr. Pastor wrote:
>
>>Any reply?
>>

>
>
> ahem. three replies, when i counted:
> http://groups.google.com/group/comp....c8455251e616c/
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments