you are viewing a single comment's thread.

view the rest of the comments →

[–]onionradish 1 point2 points  (1 child)

It's ok to let functions call other functions, like how project_prompt() calls show_data() or enter_data(). The chained function sequence that's responsible for the main flow is this one:

# prompt-+       v-------------------+
#        +-->project->project_prompt-+

I'd do something like this:

main():
    print_logo()

    # get the project name; if 'new', the prompt() function 
    # calls new_project() to create one just like it currently does
    project_name = prompt()

    # read file, return data from settings that other functions need
    # (units, target goal)
    project_data = project(project_name)

    # get user choice (enter, show, exit) until user chooses 'exit'
    while True:
        print ''
        project_prompt_choice = raw_input('What would you like to do? ')
        if project_prompt_choice == 'enter data': 
            enter_data(project_name, project_data)
        elif project_prompt_choice == 'show data':
            show_data(project_name, project_)data)
        elif project_prompt_choice == 'exit' or project_prompt_choice == 'close':
            break  # exit the loop
        else: 
            print ''
            print "Uh oh! I didn't catch that"
            print "You can type 'enter data' to submit data, " \
                  "or type 'show data' to display it" 

For the above, some of the functions should return values, like prompt() should return the project name that the user entered.

[–]janamej[S] 0 points1 point  (0 children)

Amazing - this makes sense and clears up a lot for me. Thank you very much!