the meaning of rユ.......ï¾

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon Jul 23 18:33:45 CEST 2012


On Mon, 23 Jul 2012 15:24:21 +0200, Henrik Faber wrote:

> I disagree. Firstly, Python could already support the different types of
> strings even with the ASCII character set. For example, the choice could
> have made to treat the apostophe string 'foo' differently from the
> double quote string "foo". Then, the backtick could have been used
> `foo`.

In Python 2, backticks are a synonym for the repr() function:

py> x = object()
py> `x`
'<object object at 0xb7ec7470>'

That's gone in Python 3.


> Bash for example uses all three and all three have very different
> meanings. Python is different: explicit is better than implicit, and I'd
> rather have the "r" the signifies what weird magic is going on instead
> of having some weird language rules. It would not be different with some
> UTF-8 "rawstring" magic backticks.


I'm not entirely sure why you think that r"..." is more explicit than 
some other quote marks, say `...`. Apart from the mnemonic "r for raw-
string", they're both equally mysterious language rules. (Just try 
explaining why backslashes in raw-strings are normal characters, *unless* 
the last character of the string is a backslash.)

py> print r"ab\"
  File "<stdin>", line 1
    print r"ab\"
               ^
SyntaxError: EOL while scanning single-quoted string


0_o

Personally, I like Python's quoting rules, even with quirks like the 
above. I don't like quoting rules that magically evaluate expressions or 
interpolate variables.


> Secondly, there's a reason that >=, <= and friends are in use. Every
> keyboard has a > key and every keyboard has a = key. I don't know any
> that would have >=, <= or != as UTF-8. It is useful to use only a
> limited set of characters.

You don't need a keyboard with a bazillion keys. You just need a keyboard 
with a couple of extra modifier keys, and some good mnemonics for what 
characters go with what keys. Plus a mechanism for entering arbitrary 
code points that otherwise aren't attached to a key.

Hey, if the Japanese and Chinese can manage it, English speakers can 
surely find a way to enter π or ∞ without a keyboard the size of a 
battleship.


> And if I think of PHP's latest fiasco that happened with unicode
> characters, it makes me shudder to think you'd want that stuff in
> Python. 

Oh please. Just because the PHP "designers" couldn't design a hammer 
doesn't mean that the idea of hammers is faulty.

(Cynical about PHP? Who, me?)


> If I remember correctly, it was the Turkish locale that they
> stuggled with: Turkey apparently does not have a capital "I", 

Not exactly. It has two.

Unlike most other European languages, Turkish and a few other languages 
includes both a dotted and dotless I. Other languages mix them up: dotted 
lowercase i goes with dotless uppercase I, like in English. But in 
Turkish, you have ı <=> I and i <=> İ.

http://en.wikipedia.org/wiki/Dotted_and_dotless_I

And if this wasn't so serious, it would be hilarious:

http://gizmodo.com/382026/a-cellphones-missing-dot-kills-two-people-puts-three-more-in-jail




-- 
Steven



More information about the Python-list mailing list