Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #64995 > unrolled thread

end quote help for a newbie

Started byPeter Clark <artomishka@yahoo.co.uk>
First post2014-01-30 13:26 +0000
Last post2014-01-30 14:40 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  end quote help for a newbie Peter Clark <artomishka@yahoo.co.uk> - 2014-01-30 13:26 +0000
    Re: end quote help for a newbie Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-30 14:40 +0000

#64995 — end quote help for a newbie

FromPeter Clark <artomishka@yahoo.co.uk>
Date2014-01-30 13:26 +0000
Subjectend quote help for a newbie
Message-ID<mailman.6133.1391088558.18130.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

There is probably an easy solution to this – but I have not found it.

Trying to terminate a literal in a print statement (from the 
tutorial).

The literal should be enclosed in double quotes “ “

the initial double quote seems to be OK (if I use a different character it 
flags it) but the ending is flagged as invalid syntax.  I have tried changing my 
keyboard from UK to USA, without any effect, and tried adding a space after the 
final double quote,

thanks for any assistance,

peter

[toc] | [next] | [standalone]


#65011

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2014-01-30 14:40 +0000
Message-ID<52ea647b$0$29972$c3e8da3$5496439d@news.astraweb.com>
In reply to#64995
On Thu, 30 Jan 2014 13:26:16 +0000, Peter Clark wrote:

> There is probably an easy solution to this – but I have not found it.
> 
> Trying to terminate a literal in a print statement (from the tutorial).

I don't understand the problem. Perhaps if you show us what you have 
tried, and the error you get? Please copy and paste both your code and 
the full error, from the first line starting with "Traceback" and ending 
with the error message.

Regardless of using print or not, you terminate strings with a matching 
quotation mark. If you start the string with a double-quote, you 
terminate it with the same double-quote. If you use a single-quote, the 
same applies. These two are okay:

"Double quote"
"Single quote"

But not this:

"Mixed quotes'
'Mixed quotes"


> The literal should be enclosed in double quotes “ “

What editor are you using? If you are typing your code in Microsoft 
Office, you're going to have a bad time. At the very least, you need to 
turn "Smart Quotes" off. Python will not accept curly quotes such as ‘’ 
or “” or any of the various other quotation marks, only plain old 
typewriter quotation marks ' and " (actually, these are foot and inch 
marks, but everyone treats them as if they were quotation marks).


> the initial double quote seems to be OK (if I use a different character
> it flags it) but the ending is flagged as invalid syntax.  I have tried
> changing my keyboard from UK to USA, without any effect, and tried
> adding a space after the final double quote,

UK or USA keyboard won't make any difference. You need to use an ordinary 
text editor (or better still, a programmer's text editor) but not a word 
processor such as Word. If you must use Word, disable "Smart Quotes". 
That will avoid at least one source of problems.



-- 
Steven

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web