Python for Birthday (but having tech difficulties)

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Oct 2006
Posts: 76
Reputation: mruane is an unknown quantity at this point 
Solved Threads: 1
mruane mruane is offline Offline
Junior Poster in Training

Python for Birthday (but having tech difficulties)

 
0
  #1
Oct 27th, 2006
My fiance is having a birthday in less than 20 days. I am therefore trying to create a program for her (trust me, it is not intended to be the only gift) to play around with, and hopefully enjoy. The only problem I am having so far, is that when I run the program through the Idle GUI shell, I either get a -------RESTART-------- or nothing at all. I will post the problem code below in a minute, but have one other question. I intend on having this program share multiple .pyw files. I have it coded to call the files by using import file. Do I need to import file.pyw or call it in a completely different way. I would appreciate any help, especially prompt help, because she will be home in two hours and that's all the time I get to work on it a day.
  1. print '''PyMat 2000 presents.....Secret Garden.
  2. Concieved on 10/26/06 for Denay L. Ruane.'''
  3. print
  4.  
  5. def denaystart():
  6. denaystart = raw_input("What is your name?").lower()
  7. if denaystart == "denay" or "denay wiles":
  8. print '''Welcome to your secret garden, Sailboat! This program is
  9. designed to give you something to entertain yourself with when you
  10. are very bored (we all know how bored you would have to be to play with
  11. stupid programs like mine!) There are a few things you can do with this program,
  12. here are the commands that let you do some of them...
  13. PLAY GAMES, and have WORD FUN. There are more coming to you, so be
  14. patient. My Creator, The Almighty One, has only limited time to work on
  15. me. Enjoy your gift, Denay.'''
  16. print
  17. denaylogged()
  18. else:
  19. print "Access Denied due to improper Identity Clearance."
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 1,546
Reputation: Ene Uran has a spectacular aura about Ene Uran has a spectacular aura about 
Solved Threads: 174
Ene Uran's Avatar
Ene Uran Ene Uran is offline Offline
Posting Virtuoso

Re: Python for Birthday (but having tech difficulties)

 
0
  #2
Oct 27th, 2006
Import is only for Python files that are written as modules. If you want to execute an external Python program use execfile("myfile.py") or execfile("myfile.pyw").

In your program the line if denaystart == "denay" or "denay wiles":is wrong.
It should be if denaystart == "denay" or denaystart == "denay wiles": or simpler if "denay" in denaystart:
drink her pretty
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 134
Reputation: LaMouche is on a distinguished road 
Solved Threads: 20
LaMouche's Avatar
LaMouche LaMouche is offline Offline
Junior Poster

Re: Python for Birthday (but having tech difficulties)

 
0
  #3
Oct 27th, 2006
If this is your only code, I advise that you call the function denaystart().
Last edited by LaMouche; Oct 27th, 2006 at 2:16 pm.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 16
Reputation: Zonr_0 is an unknown quantity at this point 
Solved Threads: 3
Zonr_0 Zonr_0 is offline Offline
Newbie Poster

Re: Python for Birthday (but having tech difficulties)

 
0
  #4
Oct 27th, 2006
What do you mean by
denaylogged()?

Is that a function you defined earlier?
Last edited by Zonr_0; Oct 27th, 2006 at 2:11 pm.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 76
Reputation: mruane is an unknown quantity at this point 
Solved Threads: 1
mruane mruane is offline Offline
Junior Poster in Training

Re: Python for Birthday (but having tech difficulties)

 
0
  #5
Oct 28th, 2006
To Ene Uran, thank you for the clarification. To Zonr 0, denaylogged() is a later defined function. I am attempting to write it so that it is password protected. So, her name acts as the password I guess. denaylogged() is the function that denaystart() calls if in denaystart = "denay" or "denay wiles". Although I guess I need to relearn that part of my code. I didn't put all of the code I wrote up because I figured it would just waste space or something. Don't mind me, just a little bit of programming insecurity.
La Mouche, you seem to understand classes very well, would using a class be better than a function or are they two complete different things meant for different purposes?
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 76
Reputation: mruane is an unknown quantity at this point 
Solved Threads: 1
mruane mruane is offline Offline
Junior Poster in Training

Re: Python for Birthday (but having tech difficulties)

 
0
  #6
Oct 28th, 2006
I also have a questions regarding posting in threads. I gather that you start a new thread for a new topic, but I am unsure of where to post this question. It has to do with my birthday gift in python, but also to do with another aspect of python usage, creating A.I. Or at least simulating it. Do I post a new thread?
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 134
Reputation: LaMouche is on a distinguished road 
Solved Threads: 20
LaMouche's Avatar
LaMouche LaMouche is offline Offline
Junior Poster

Re: Python for Birthday (but having tech difficulties)

 
0
  #7
Oct 28th, 2006
Hey there. Classes are unnecessary here. If it's still not doing anything, make sure you're calling that main denaystart() function.

If you want to ask about a new topic such as AI, then post it in another thread. Keep one question to a thread so people can look at the name and know what the thread is about.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 76
Reputation: mruane is an unknown quantity at this point 
Solved Threads: 1
mruane mruane is offline Offline
Junior Poster in Training

Re: Python for Birthday (but having tech difficulties)

 
0
  #8
Oct 30th, 2006
Well, thanks, I now have the program at least starting. I get through the name input stage, and use 'word fun' command, as that is all that is defined this far, and use 'help' because it is the only way to find out that you use 'start' to run the Codex. I also played with the indentation of the print statements contents, making it look prettier when run. But now I get a syntax error on a blank line. So, I was wondering, what are the rules for blank lines and how the heck did I not define 'start'?
  1. # this is a program intended just for my fiance
  2. # it is intended to be entertaining, sweet, and/or useful.
  3. # I will start by making one simple function and randomly expand on that
  4. # !!!!!!!! I need to define prompt_login() before I call it! !!!!!!!!!!!!
  5. def denaystart():
  6. print '''Welcome to the PyMat 2000 login. Answer the following question to run PyMat 2000.'''
  7. prompt_login()
  8. print '''PyMat 2000 presents.....Secret Garden.
  9. Concieved on 10/26/06 for Denay L. Ruane.'''
  10. print
  11.  
  12. def prompt_login():
  13. prompt_a = raw_input("What is your name? ").lower()
  14. try:
  15. if prompt_a == "denay" or prompt_a == "denay wiles":
  16. print '''Welcome to your secret garden, Sailboat! This program is
  17. designed to give you something to entertain yourself with when you
  18. are very bored (we all know how bored you would have to be to play with
  19. stupid programs like mine!) There are a few things you can do with this program,
  20. here are the commands that let you do some of them...
  21. PLAY GAMES, and have WORD FUN. There are more coming to you, so be
  22. patient. My Creator, The Almighty One, has only limited time to work on
  23. me. Enjoy your gift, Denay.'''
  24. print
  25. denaylogged()
  26. else:
  27. print "Access Denied due to improper Identity Clearance."
  28. prompt_login()
  29. # somehow there is a syntax error on this line, but there was nothing there?!
  30. def denaylogged():
  31. print '''Hello, Denay! My name is Sally, I am a Multi Purpose Platform Interactive Program,
  32. or MPPIP for short. I was designed by a blossoming programming genious to provide you with some
  33. entertainment and a friend if you need one. While talking to me is not the same as talking to a real
  34. person, I will do my best to provide you with the highest quality of virtual friendship. My A.I.
  35. is not very advanced as of yet, but I will learn as we interact. '''
  36. print
  37. prompt_dl()
  38. def prompt_dl():
  39. prompt_b = raw_input("Tell Sally: ").lower()
  40. if prompt_b == "play games" or prompt_b == "games": # if prompt_dl == "" or prompt_dl == "": ??????
  41. denaygames()
  42. elif prompt_b == "word fun" or prompt_b == "word":
  43. dencodefun()
  44. elif prompt_b == "help me" or prompt_b == "help commands":
  45. help1()
  46. else:
  47. print "I don't understand what you want. Type 'help commands' for advice. "
  48.  
  49. def dencodefun():
  50. print '''Hello Denay, this is Sally. I am here to help you with any
  51. questions you may have about this program. You are currently using Pymat 2000's
  52. Codex v1.0. This program allows you to translate words into secret code, or, decode
  53. words written in secret code. Codex v1.0 deals in a code called Ceaser Salad. Type
  54. 'help' for more help. '''
  55. print
  56. prompt_st()
  57.  
  58. def prompt_st():
  59. prompt_c = raw_input("Tell Sally:").lower()
  60. if prompt_c == "help":
  61. print '''Well, hello Denay, I assume you need some help with Codex? Alright.
  62. When you first load the program, you come to the main menu screen. Here you will
  63. choose an option that best suits your needs.
  64. Choose option (1) to Encode, or translate readable messages into Ceaser Salad code.
  65. Choose option (2) to Decode, or, translate Ceaser Salad code into readable words.
  66. Option number (3) will tell you alittle more about Codex v1.0, while
  67. Option number (4) will exit the program. REMEMBER Denay, when making a selection, type
  68. in the number of the action you wish to make, not the words. To begin the fun, type
  69. 'start'. '''
  70. elif prompt_c == "start" or prompt_c == "begin":
  71. execfile('C:\python24\pymat2000.pyw')
  72. else:
  73. print "I am yet still very young, could you type everything out so I can understand?"
  74. prompt_st()
  75.  
  76. def help1():
  77. print ''' Hello Denay, this is Sally again. I am going to help you with the command list.
  78. When you are in any program, typing 'help' at any time will call me, and I will explain to you
  79. the commands for that program. In this program your commands are 'play games', 'word games', and of
  80. course 'help'. Enter your commands with exact spelling, or I will not understand. Have fun sweetie. '''
  81. print
  82. prompt_b()
  83.  
  84. denaystart()
  85. # do I need to call denaystart() as a function to get it to work ??????????
  86. # or does it call itself ???????????/
  87. # I just can't get this program to work ??????????
  88.  
  89. # should prompt_login() be like is or should it be ??????
  90. # if prompt_a == "denay" or prompt_a == "denay wiles": ???????
  91.  
  92. # my main challenge is understanding the def function(): mechanics. ????????
  93. # is this correct: ???????????
  94. # def function():
  95. # print '''words and stuff go here ''' ???????
  96. # print
  97. # prompt_function = raw_input(""): that is my problem. ??????
  98. # do i call the user input prompt the same as the function, or did I do it right in
  99. # the example????????????
  100. # and for:
  101. # if (user input prompt) == "":
  102. # what do I call the user input prompt?
  103.  
  104. # Next step is to make sure that the Codex works
  105. # Start developing word games for the word fun section
  106. # Create a function for more info on Sally
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 134
Reputation: LaMouche is on a distinguished road 
Solved Threads: 20
LaMouche's Avatar
LaMouche LaMouche is offline Offline
Junior Poster

Re: Python for Birthday (but having tech difficulties)

 
0
  #9
Oct 31st, 2006
Here's working code.

[php]
# this is a program intended just for my fiance
# it is intended to be entertaining, sweet, and/or useful.
# I will start by making one simple function and randomly expand on that
# !!!!!!!! I need to define prompt_login() before I call it! !!!!!!!!!!!!
def denaystart():
print '''Welcome to the PyMat 2000 login. Answer the following question to run PyMat 2000.'''
prompt_login()
print '''PyMat 2000 presents.....Secret Garden.
Concieved on 10/26/06 for Denay L. Ruane.'''
print

def prompt_login():
prompt_a = raw_input("What is your name? ").lower()
try:
if prompt_a == "denay" or prompt_a == "denay wiles":
print '''Welcome to your secret garden, Sailboat! This program is
designed to give you something to entertain yourself with when you
are very bored (we all know how bored you would have to be to play with
stupid programs like mine!) There are a few things you can do with this program,
here are the commands that let you do some of them...
PLAY GAMES, and have WORD FUN. There are more coming to you, so be
patient. My Creator, The Almighty One, has only limited time to work on
me. Enjoy your gift, Denay.'''
print
denaylogged()
else:
print "Access Denied due to improper Identity Clearance."
prompt_login()
except: ## FOR EVERY TRY YOU NEED AN EXCEPT !!!!!!!!!!!!!!!!!!
pass
# somehow there is a syntax error on this line, but there was nothing there?!
def denaylogged():
print '''Hello, Denay! My name is Sally, I am a Multi Purpose Platform Interactive Program,
or MPPIP for short. I was designed by a blossoming programming genious to provide you with some
entertainment and a friend if you need one. While talking to me is not the same as talking to a real
person, I will do my best to provide you with the highest quality of virtual friendship. My A.I.
is not very advanced as of yet, but I will learn as we interact. '''
print
prompt_dl()
def prompt_dl():
prompt_b = raw_input("Tell Sally: ").lower()
if prompt_b == "play games" or prompt_b == "games": # if prompt_dl == "" or prompt_dl == "": ??????
denaygames()
elif prompt_b == "word fun" or prompt_b == "word":
dencodefun()
elif prompt_b == "help me" or prompt_b == "help commands":
help1()
else:
print "I don't understand what you want. Type 'help commands' for advice. "

def dencodefun():
print '''Hello Denay, this is Sally. I am here to help you with any
questions you may have about this program. You are currently using Pymat 2000's
Codex v1.0. This program allows you to translate words into secret code, or, decode
words written in secret code. Codex v1.0 deals in a code called Ceaser Salad. Type
'help' for more help. '''
print
prompt_st()

def prompt_st():
prompt_c = raw_input("Tell Sally:").lower()
if prompt_c == "help":
print '''Well, hello Denay, I assume you need some help with Codex? Alright.
When you first load the program, you come to the main menu screen. Here you will
choose an option that best suits your needs.
Choose option (1) to Encode, or translate readable messages into Ceaser Salad code.
Choose option (2) to Decode, or, translate Ceaser Salad code into readable words.
Option number (3) will tell you alittle more about Codex v1.0, while
Option number (4) will exit the program. REMEMBER Denay, when making a selection, type
in the number of the action you wish to make, not the words. To begin the fun, type
'start'. '''
elif prompt_c == "start" or prompt_c == "begin":
execfile('C:\python24\pymat2000.pyw')
else:
print "I am yet still very young, could you type everything out so I can understand?"
prompt_st()

def help1():
print ''' Hello Denay, this is Sally again. I am going to help you with the command list.
When you are in any program, typing 'help' at any time will call me, and I will explain to you
the commands for that program. In this program your commands are 'play games', 'word games', and of
course 'help'. Enter your commands with exact spelling, or I will not understand. Have fun sweetie. '''
print
prompt_b()

denaystart()
# do I need to call denaystart() as a function to get it to work ??????????
# or does it call itself ???????????/
# I just can't get this program to work ??????????

# should prompt_login() be like is or should it be ??????
# if prompt_a == "denay" or prompt_a == "denay wiles": ???????

# my main challenge is understanding the def function(): mechanics. ????????
# is this correct: ???????????
# def function():
# print '''words and stuff go here ''' ???????
# print
# prompt_function = raw_input(""): that is my problem. ??????
# do i call the user input prompt the same as the function, or did I do it right in
# the example????????????
# and for:
# if (user input prompt) == "":
# what do I call the user input prompt?

# Next step is to make sure that the Codex works
# Start developing word games for the word fun section
# Create a function for more info on Sally
[/php]

A "try" needs an "except." I fixed this in your prompt_login() function. At least it will run now.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Python Forum
Thread Tools Search this Thread



Tag cloud for Python
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC