Python Forum

Full Version: Use a class type in it
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,
I want to use a description for my parameter of my class method and that give this
class Player:
    def __init__(self, name: str) -> None:
        self.name = name

    def battle(self, opponent: Player) -> int:
        print(f"Battle betwen {self.name} and {opponent.name}")
        return 0
(It's the :Player who don't work)
If anyone have an idea.
Thanks in advance.
Use : "Player" instead of : Player.
(Jan-28-2023, 11:19 PM)Gribouillis Wrote: [ -> ]Use : "Player" instead of : Player.

Ok it work now
Thanks