Reputation: 185
I suspect the static method tag is not detected or something.
>class Employee:
> @staticmethod
> def dayIsWorkday(day):
> if day.weekday() == 5 or day.weekday() == 6:
> return False
> return True
>
>
>import datetime
>my_date = datetime.date(2018, 12, 5)
>
>print(Employee.dayIsWorkday(my_date))
File "C:/Users/tronc/PycharmProjects/oop_TEST/main.py", line 26 def dayIsWorkday(day): ^ SyntaxError: invalid syntax
Process finished with exit code 1
You may think that it's not useful, i think that too, but it's for a tutorial i'm trying to follow and i don't wanna go any further till i get what i done wrong
Upvotes: 0
Views: 110
Reputation: 378
I guess its an indentation error. Check this
class Employee:
@staticmethod
def dayIsWorkday(day):
if day.weekday() == 5 or day.weekday() == 6:
return False
return True
import datetime
my_date = datetime.date(2018, 12, 5)
print(Employee.dayIsWorkday(my_date))
Upvotes: 1
Reputation: 24905
There should be no indentation for the function name in the next line after @staticmethod
>class Employee:
> @staticmethod
> def dayIsWorkday(day):
> if day.weekday() == 5 or day.weekday() == 6:
> return False
> return True
>
>
>import datetime
>my_date = datetime.date(2018, 12, 5)
>
>print(Employee.dayIsWorkday(my_date))
Upvotes: 1