Python inheritance with functions without running function -


say if had this:

def player():     your_player = character()     battle(your_player) # <-- automatically runs battle - dont want  def battle(your_player):     #etc def main(): # want functions ran in function     # not in other functions     player()     battle() 

but, wanted make when variable gets inherited, doesn't run, can run in single main function.

how can this?

if haven't explained clearly, ask.

it sounds want battle method of character class. can add definition so:

class character:     # rest of definition     def battle(self):         # definition of battle function 

and use like

def main():     player = character()     player.battle() 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -