3
def success(self, input1: str = "", input2: str = "", input3: str = "") -> None:
E                               ^
E   SyntaxError: invalid syntax

No idea what is happening here..

Code:

 def success(self, input1: str = "", input2: str = "", input3: str = "") -> None:
        input1 = str(input1)
        input2 = str(input2)
        input3 = str(input3)
        print(Color.BOLD + Color.GREEN + " " + Color.CHECKMARK + " " + input1 + Color.END + " " + input2 + " " + input3)
2
  • 6
    What Python version are you using? Parameter type hints are a relatively new addition. Commented Jan 8, 2019 at 23:37
  • I guess you are correct. Could have seen it. Its using Python 2.7, but pretty sure I need newer. Im on Mac. I got it brewed all in, no idea how to correct, seems like different Q. Commented Jan 8, 2019 at 23:41

2 Answers 2

6

Since you're on Python 2.7, you need to back up to that syntax. Type hints are Python 3; remove them.

def success(self, input1="", input2="", input3=""):
Sign up to request clarification or add additional context in comments.

Comments

3

The function you posted is valid Python 3.7. Type hints were added to Python in version 3.5.0, the code you posted should work in any version from 3.5.0 onwards:

Python 3.7.0 (default, Aug 22 2018, 20:50:05) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> def success(self, input1: str = "", input2: str = "", input3: str = "") -> None:
...         input1 = str(input1)
...         input2 = str(input2)
...         input3 = str(input3)
...         print(Color.BOLD + Color.GREEN + " " + Color.CHECKMARK + " " + input1 + 
Color.END + " " + input2 + " " + input3)
... 
>>> success
<function success at 0x7fb70e4c61e0>

I suspect you are using an older python version that does not support these language features.

Comments

Your Answer

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.