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