I want to specify a parameter in one of my classes in python to have a more legible code.
All types work (str, int, list, etc.) but not class.
How can ? specify that my parameter enemy in the function attack of Character is a class ? (or even the specific class Enemy).
class Character:
def __init__(self, life_stat, attack_stat, healing_stat):
self.life_stat = life_stat
self.attack_stat = attack_stat
def attack(self, enemy):
enemy.life_stat += -self.attack_stat
class Enemy:
def __init__(self, life_stat, attack_stat):
self.life_stat = life_stat
Thanks for the support.
I tried with :
enemy: class (Not working because it want to create a new class)
enemy: Enemy (Not working because Enemy is not already defined)
New contributor
Pierrike Steam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.