help needed to understand an error message.

J. Cliff Dyer jcd at sdf.lonestar.org
Fri Mar 30 21:51:42 EDT 2012


So the problem is that python doesn't know what you're trying to do.  It
doesn't know that you meant to say "print."  When the parser is looking
at the word Print, it assumes you are referencing an object named Print,
which is completely legal.  It's only once you've created the next
token, a string literal, that the parser discovers the error: you can't
have a string literal following a variable.  

*You* think your error is that you misspelled "print."  The parser
thinks your error is trying to put a string literal next to a variable.

Cheers,
Cliff


On Mon, 2012-03-26 at 18:22 +0530, Aloke Ghosh wrote:
> Hi,
> I am learning Python and do not have programming experience.
> I was following
> an exercise from http://learnpythonthehardway.org/book/ex2.html
> and made a mistake in entry :
> 
> 
> Print"I like typing this." 
> 
> 
> and got the following error message:
> 
> 
> In [2]: Print"I like typing this."
> ------------------------------------------------------------
>    File "<ipython console>", line 1
>      Print"I like typing this."
>                                         ^
> SyntaxError: invalid syntax
> 
> 
> I feel the error is in Capital P in print .
> However the error indicated with "^" 
> hints at quote at the end of the line.
> 
> 
> Can any one please help me understand this.
> 
> 
> -- 
> A.K.Ghosh





More information about the Python-list mailing list