[Python-ideas] Smart/Curly Quote Marks and cPython

Steven D'Aprano steve at pearwood.info
Sat Oct 22 03:16:37 EDT 2016


On Sat, Oct 22, 2016 at 06:13:35AM +0000, Jonathan Goble wrote:
> Interesting idea. +1 from me; probably can be as simple as just having the
> tokenizer interpret curly quotes as the ASCII (straight) version of itself
> (in other words, " and the two curly versions of that would all produce the
> same token, and same for single quotes, eliminating any need for additional
> changes further down the chain).

There's a lot more than two. At least nineteen (including the ASCII 
ones): 〝〞〟"'"'«»‘’‚‛“”„‟‹›


> This would help with copying and pasting
> code snippets from a source that may have auto-formatted the quotes without
> the original author realizing it.

Personally, I think that we should not encourage programmers to take a 
lazy, slap-dash attitude to coding. Precision is important to 
programmers, and there is no limit to how imprecise users can be. Should 
we also guard against people accidentally using prime marks or ornaments 
(dingbats):

′″‴‵‶‷ ❛❜❝❞❮❯

as well? If not, what makes them different from other accidents of 
careless programmers?

I don't think we should be trying to guess what programmers mean, nor do 
I think that we should be encouraging programmers to use word processors 
for coding. Use the right tool for the right job, and even Notepad is 
better for the occasional programmer than Microsoft Office or 
LibreOffice. Programming is hard, requiring precision and care, and we 
don't do beginners any favours by making it easy for them to be 
imprecise and careless.

I would be happy to see improved error messages for smart quotes:

py> s = ‘abcd’
  File "<stdin>", line 1
    s = ‘abcd’
             ^
SyntaxError: invalid character in identifier

(especially in IDLE), but I'm very dubious about the idea of using 
typographical quote marks for strings. At the very least, Python should 
not lead the way here. Let some other language experiment with this 
first, and see what happens. Python is a mature, established language, 
not an experimental language.

Of course, there's nothing wrong with doing an experimental branch of 
Python supporting this feature, to see what happens. But that doesn't 
mean we should impose it as an official language rule.



-- 
Steve


More information about the Python-ideas mailing list