Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Same mistake but different error report. Why?

Why Python reports about different errors for the same reason, the programs with the 1 and 2 lines of code?

I mean:

print(1

gives

Error: unexpected EOF while parsing

but

a = 1+1
print(1

gives

Error: invalid syntax

same problem - but error message is different - reason?

sys.version_info(major=3, minor=2, micro=0, releaselevel='final',serial=0)

like image 430
user1810077 Avatar asked Nov 08 '12 17:11

user1810077


People also ask

Why do we keep making same mistakes?

When we do something right, a pathway is created. Unfortunately, a pathway is also created when we something wrong. We basically build habits this way, both good and bad. So the reason we keep making the same mistakes is that we slip by default back into existing neural pathways.

Is it normal to make the same mistake twice?

Sometimes, it is necessary for us to make mistakes several times, in order for us to fully learn and grow from them. Even if it is the same mistake. Reconcile with the fact that you are human. You will never be perfect and you need to go easy on yourself.

When an employee repeatedly makes the same mistake?

When an employee repeatedly makes the same mistake gives him a chance to correct himself it is known as warning.


1 Answers

In your first case python is 'looking' for its FIRST line/command. The minimum for a program is at least one statement. So it complains about early termination.

So the first error EOF (end of File) means: 'Hey I was expecting at least one command and suddenly the line ended...' 'Are you sure the program is completed?'

The second error the previous was run so the compiler 'knows' that this is a program.

and the error is different but it means:

'Hey I for now you have a error in this position, can you fix your sintaxe'?

I hope my non academic way do not distracted you :)

like image 148
Carlos Henrique Cano Avatar answered Sep 20 '22 06:09

Carlos Henrique Cano