Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
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 December 2nd, 2004, 01:28 PM
monkeyman23555 monkeyman23555 is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2004
Location: There where the rabbits jump
Posts: 556 monkeyman23555 User rank is Corporal (100 - 500 Reputation Level)monkeyman23555 User rank is Corporal (100 - 500 Reputation Level)monkeyman23555 User rank is Corporal (100 - 500 Reputation Level)monkeyman23555 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 20 h 51 m 15 sec
Reputation Power: 6
Send a message via MSN to monkeyman23555
Exclamation raw_input (???)

I have many scripts that I want to convert to exes but it just does not work because it always says that a EOF Error has come in this script:

while 1:
print "calc for a calculator"
print "fib for the Fibonacci Sequnence"

a= raw_input("Which option would you like to choose?")

if a== "calc":
import Calc
print Calc

elif a== "fib":
import Fibonacci
print Fibonacci

in the fifth line by the raw_input("Which option would you like to choose")

And an other question how do u exit a module but then u can go into it again is it with "reload" but i dont understand.

please help me

Reply With Quote
  #2  
Old December 2nd, 2004, 08:35 PM
Yegg`'s Avatar
Yegg` Yegg` is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Dec 2004
Location: Meriden, Connecticut
Posts: 1,731 Yegg` User rank is Second Lieutenant (5000 - 10000 Reputation Level)Yegg` User rank is Second Lieutenant (5000 - 10000 Reputation Level)Yegg` User rank is Second Lieutenant (5000 - 10000 Reputation Level)Yegg` User rank is Second Lieutenant (5000 - 10000 Reputation Level)Yegg` User rank is Second Lieutenant (5000 - 10000 Reputation Level)Yegg` User rank is Second Lieutenant (5000 - 10000 Reputation Level)Yegg` User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 3 Weeks 6 Days 4 h 5 m 27 sec
Reputation Power: 83
Send a message via AIM to Yegg`
Hmm, I would like to help you with your raw_input problem only your question doesn't seem to make much sense. Also the line, "in the fifth line by the line "raw_input("Which option would you like to choose")" seems to be randomly placed. Because of this I have no clue what exactly you need help with.

Reply With Quote
  #3  
Old December 3rd, 2004, 05:06 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: 8
Send a message via MSN to Grim Archon
You are using the import command to run code in your modules. This is the problem.

You are right; the only way to re-execute the module would be to use the reload command. But this is not necessary. Normally, code run at import time is only used to configure the module or prepare things for later execution. Your modules need some functions that you can call after the module is imported...

I suggest you investigate writing functions, you can then do things like:
Code:
import fibonacci
import calc

while True:
    a = raw_input("Type 'calc'' or 'fib' or 'quit'")
    if a not in ['calc','fib','quit']:
        continue
    if a == 'quit':
        break
    if a == 'fib':
        fibonacci.do_fibonacci() # do_fibonacci is a function you write in  the fibonacci module.
    elif a =='calc':
        calc.do_calc() #do_calc is a function in the calc module


In your calc module you could have a function like this:
Code:
def do_calc():
    #the code to do calculations


I hope this helps

grim

p.s. use code tags!
__________________
*** Experimental Python Markup CGI V2 ***

Reply With Quote
  #4  
Old December 3rd, 2004, 02:35 PM
monkeyman23555 monkeyman23555 is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2004
Location: There where the rabbits jump
Posts: 556 monkeyman23555 User rank is Corporal (100 - 500 Reputation Level)monkeyman23555 User rank is Corporal (100 - 500 Reputation Level)monkeyman23555 User rank is Corporal (100 - 500 Reputation Level)monkeyman23555 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 20 h 51 m 15 sec
Reputation Power: 6
Send a message via MSN to monkeyman23555
ya but could you please explian the "def" thingy because i dont understand it
and please some examples

Reply With Quote
  #5  
Old December 3rd, 2004, 06:35 PM
Boki's Avatar
Boki Boki is offline
A wanna-be guru of some sort
Dev Shed Novice (500 - 999 posts)
 
Join Date: Sep 2004
Location: Either online or offline
Posts: 624 Boki User rank is Sergeant (500 - 2000 Reputation Level)Boki User rank is Sergeant (500 - 2000 Reputation Level)Boki User rank is Sergeant (500 - 2000 Reputation Level)Boki User rank is Sergeant (500 - 2000 Reputation Level)Boki User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 4 h 7 m 13 sec
Reputation Power: 14
Quote:
Originally Posted by monkeyman23555
ya but could you please explian the "def" thingy because i dont understand it
and please some examples
OK
Code:
  def show(something):
     print something
  
  show("A string")
  A string
  list = [1, 2, 3]
  show(list)
  [1, 2, 3]
  


You gotta have parentheses after the function name, even if there are no parameters to the function, gotta have a colon after parentheses, and the body of the function has to be consistently indented.

Code:
  def multiply(a, b):
     return a*b
  
  
  multiply(2.5, 4)
  10.0
  
  

Reply With Quote
  #6  
Old December 4th, 2004, 05:31 AM
monkeyman23555 monkeyman23555 is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2004
Location: There where the rabbits jump
Posts: 556 monkeyman23555 User rank is Corporal (100 - 500 Reputation Level)monkeyman23555 User rank is Corporal (100 - 500 Reputation Level)monkeyman23555 User rank is Corporal (100 - 500 Reputation Level)monkeyman23555 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 20 h 51 m 15 sec
Reputation Power: 6
Send a message via MSN to monkeyman23555
hm i get it a bit but wait
is it just like a thing name and then it just if u type that it asks u for the (a, b)and then it multiplys them like that oh ok thats good i am going to try something and then put the script put here
thanks

Reply With Quote
  #7  
Old December 4th, 2004, 01:19 PM
Boki's Avatar
Boki Boki is offline
A wanna-be guru of some sort
Dev Shed Novice (500 - 999 posts)
 
Join Date: Sep 2004
Location: Either online or offline
Posts: 624 Boki User rank is Sergeant (500 - 2000 Reputation Level)Boki User rank is Sergeant (500 - 2000 Reputation Level)Boki User rank is Sergeant (500 - 2000 Reputation Level)Boki User rank is Sergeant (500 - 2000 Reputation Level)Boki User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 4 h 7 m 13 sec
Reputation Power: 14
No, this does not ask the user for a, b, but you could make it so
Code:
  x = input("Please enter the first number: ")
  y = input("Please enter the second number: ")
  

And then you can call the multiply(a, b) function like this:
Code:
multiply(x, y)
__________________
Am I supposed to sign here?

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > raw_input (???)


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT