Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 2nd, 2004, 04:20 AM
winxptipster winxptipster is offline
James
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: Beer Sheva, Israel
Posts: 12 winxptipster User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 27 sec
Reputation Power: 0
Real time vs script commands

I am just getting started with Python and so far it is very good.

Since this is a forum, I am supposed to ask a question, right?

Okay, here it is. How can I tell which commands are for real time only (IDLE), and which ones are for scripts?

Okay, there it is.

Have a nice day.....

Reply With Quote
  #2  
Old April 2nd, 2004, 05:49 AM
Grim Archon's Avatar
Grim Archon Grim Archon is offline
Mini me.
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2003
Location: Cambridge, UK
Posts: 783 Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)  Folding Points: 1488 Folding Title: Novice Folder
Time spent in forums: 3 Days 2 h 15 m 57 sec
Reputation Power: 12
Send a message via MSN to Grim Archon
The only thing I know that is specific to IDLE is
_ which always contains the last result calculated and the evaluation of expressions like 1+1 without assignment to a name. Everything else that you can do on the interactive console you can include in your programs.
Console only:
Code:
>>> 8+2
10
>>> _
10
>>> 

I am guessing you don't mean IDLE editing commands like Alt-P, CTRL-X, F5 etc.
__________________
*** Experimental Python Markup CGI V2 ***

Reply With Quote
  #3  
Old April 2nd, 2004, 06:59 AM
winxptipster winxptipster is offline
James
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: Beer Sheva, Israel
Posts: 12 winxptipster User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 27 sec
Reputation Power: 0
Thanks for the reply....
Here is an example of what I am talking about.....

In a script, I write:
testlist =("one","two","three","four","five")
print testlist
len(testlist)

The only outpt is from the print testlist command.
The len(testlist) doesn't produce anything.

The same code written in real time (IDLE) produces both the print as well as the len command.

Which makes me wonder how I'm supposed to differentiate between the cans and cannots.

Reply With Quote
  #4  
Old April 2nd, 2004, 09:35 AM
Grim Archon's Avatar
Grim Archon Grim Archon is offline
Mini me.
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2003
Location: Cambridge, UK
Posts: 783 Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)  Folding Points: 1488 Folding Title: Novice Folder
Time spent in forums: 3 Days 2 h 15 m 57 sec
Reputation Power: 12
Send a message via MSN to Grim Archon
The interactive console is special - expressions are always evaluated for printing on the screen. So when you type len(something) it prints the result. You could call this a "side-effect" of using the interactive console. It makes your life easier for testing out code.

In a program you don't want "side-effects". You only get things printed if you explicitly use the print command.
In a program having the expressions
1+1
len(something)
on there own line is pointless because nothing happens to the result.

Reply With Quote
  #5  
Old April 2nd, 2004, 10:31 AM
winxptipster winxptipster is offline
James
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: Beer Sheva, Israel
Posts: 12 winxptipster User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 27 sec
Reputation Power: 0
All right.... I appreciate your response.

I think I understand what you are saying, as it makes a lot of sense. Again, thanks a lot...

Reply With Quote
  #6  
Old April 2nd, 2004, 11:40 AM
DevCoach DevCoach is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2004
Location: London, England
Posts: 1,585 DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 2 h 58 m 23 sec
Reputation Power: 1372
One other point that Grim didn't mention. If you enter a line in the interactive shell that returns None, then it is not printed. This may be what confused you in the first place. Functions that do not explicitly return a value always return None.

e.g.

Code:
>>> 
>>> 123
123
>>> None
>>> import os
>>> os.getcwd()
'C:\\dev\\Python23\\lib\\site-packages'
>>> os.chdir('C:/')
>>> 


The import statement and chdir do not have a return value, so nothing is printed.

Dave - The Developers' Coach

Reply With Quote
  #7  
Old April 2nd, 2004, 02:04 PM
winxptipster winxptipster is offline
James
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: Beer Sheva, Israel
Posts: 12 winxptipster User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 27 sec
Reputation Power: 0
Ahhh, things are beginning to clear up even more.

I certainly do thank the both of you.

Now, watch my smoke....(puff)

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Real time vs script commands

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap