0

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
3
  • What is the error? Commented Jul 18, 2018 at 8:46
  • i posted it now Commented Jul 18, 2018 at 8:47
  • You shouldn't indent the code after your decorator. Commented Jul 18, 2018 at 8:47

2 Answers 2

1

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
Sign up to request clarification or add additional context in comments.

Comments

1

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))
answered Jul 18, 2018 at 8:48

2 Comments

oh nevermainf i forget the paranteses from the class method above so it wuldnt close corrrect thanks bye
I guess you have an error in another part of your code now.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.