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
asked Jul 18, 2018 at 8:44
Morton Madison Wally
1851 gold badge1 silver badge5 bronze badges
-
What is the error?Jay– Jay2018年07月18日 08:46:27 +00:00Commented Jul 18, 2018 at 8:46
-
i posted it nowMorton Madison Wally– Morton Madison Wally2018年07月18日 08:47:10 +00:00Commented Jul 18, 2018 at 8:47
-
You shouldn't indent the code after your decorator.pask– pask2018年07月18日 08:47:56 +00:00Commented Jul 18, 2018 at 8:47
2 Answers 2
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))
answered Jul 18, 2018 at 8:47
Jay
25.1k25 gold badges100 silver badges143 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
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))
2 Comments
Morton Madison Wally
oh nevermainf i forget the paranteses from the class method above so it wuldnt close corrrect thanks bye
sjaymj62
I guess you have an error in another part of your code now.
lang-py