Joseph,

I don't know if this will help or not, but some observations:

> def manipulate():
>      manipulate = raw_input("Type 'help' for help\nManipulate>> ")
>      if manipulate == "play":
>          w.tell()
>      elif manipulate == "back()":
>          main_menu()

You expect the user to type 'play' or 'back()'
One response is a command the other a pseudo function call
complete with parentheses. Thats not a very consistent user
experience.

Also by calling main_menu from inside manipulate you are effectively
using recursion as a loop. Thats OK if the number of loops is
small but if this program were used over a long preiod you
will eventually run out of menory.

Its usually better to return a value and have a main control
loop somewhere that calls the functions. For example have your
main_menu function display the prompt, sanity check the input
and return a valifd response from the user. Then have a single
if/elif tree dispatch the appropriate function that returns
success or failure. Wrap the menu and if/elif tree inside a
loop that exits on error or command.

That way ypur program can run indefinitely without risk of
memory overflow.

def main_menu():
    ....
    return choice

while True:
    choice = main_menu()
    if choice == 'foo':
       foo()
    elif chooice == 'bar':
       bar()
    # etc...
    elif choice == 'exit'
       break
    else: break


> ... to play a .wav music file. I tried w.play() but got an error
that
> module has no attribute 'play'.

Have you used dir(w) to see what it does offer? Even better what does
the documentation say? Have you tried help(w)?

HTH,

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to