python - Global Function block? -


i making game in python. whenever want in game, type help , can read section.

the problem is, need add function block each level.

def level_01():     choice = raw_input('>>>: ')     if choice=='help':         level_01_help()   def level_012():     choice = raw_input('>>>: ')     if choice=='help':         level_02_help() 

so wondering if possible make global function block levels? when enter help, help(), , automatically goes function block came from.

i hope understand mean, , appreciate get.

you can pass function paramater, meaning code can become:

def get_choice(help_func):     choice = raw_input('>>>: ')     if choice == 'help':         help_func()     else:         return choice  def level_01():     choice = get_choice(level_01_help)  def level_02():     choice = get_choice(level_02_help) 

ideally should have separate module interface related tasks, game , interface 2 seperate entities. should make 2911 lines bit more legible, , if decide change interfaces (from command line tkinter or pygame example) have much easier time of it. 2¢


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -