Python Forum

Full Version: invalid syntax in my class
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, i've just written my first class ever and it doesn't work...

Here it is:

class Player:

    hand = []
    playershand = []
    playersgrade = []

    dealer = False
    smallblind = False
    bigblind = False
    
    def __init__(self, number, chips):
        self.number = number
        self.chips = chips

    def bet(self):
        print("Bet")

    def raise(self):
        pass
    def call(self):
        pass
    def check(self):
        pass
    def fold(self):
        pass
    def quit(self):
        pass
    def showstats(self):
        pass
    
and here's the error:

Error:
Traceback (most recent call last): File "/usr/lib/python3.8/idlelib/run.py", line 559, in runcode exec(code, self.locals) File "/home/fook/Documents/pygame/Poker Practice/Poker.py", line 4, in <module> from playerclass import Player File "/home/fook/Documents/pygame/Poker Practice/playerclass.py", line 18 def raise(self): ^ SyntaxError: invalid syntax
So i don't know, my colon is there , paranthesis and my indentation too... And it looks just like the tutorial...
So what did i do wrong?
I just saw it when I posted my question...

raise is a reserved term in python so i can't use it as a function name...

Sorry, my text editor is not as good as the forum's...
CompleteNewb Wrote:Sorry, my text editor is not as good as the forum's...
Perhaps you should look into one of the open source IDE's there are many available.
two of the best (In my opinion) are VSCode and PyCharm.
there are many more available (google: 'python IDE's') and you should try as many as you wish until you find one you like.