[Tutor] error message

Steven D'Aprano steve at pearwood.info
Thu Mar 21 07:01:33 EDT 2019


> I don't understand this error message. Thank you so much, Glenn Dickerson
> 
> Traceback (most recent call last):
>   File "/home/glen/app.py", line 1, in <module>
>     import Student
>   File "/home/glen/Student.py", line 2
>     def__init__(self, name, major, gpa, is_on_probation):
>                                                         ^
> SyntaxError: invalid syntax


Syntax errors are sometimes the hardest to decipher, because the message 
is usually pretty generic and uninformative, and the caret ^ will appear 
where the interpreter *notices* the problem, not where the problem 
*starts*.

In this case, the problem is you are missing a space between the "def" 
keyword and the "__init__" method name.


-- 
Steven


More information about the Tutor mailing list