Unrecognized escape sequences in string literals

Douglas Alan darkwater42 at gmail.com
Mon Aug 10 10:11:33 EDT 2009


On Aug 10, 4:37 am, Steven D'Aprano

> There is at least one good reason for preferring an error, namely that it
> allows Python to introduce new escape codes without going through a long,
> slow process. But the rest of these complaints are terribly unconvincing.


What about:

   o Beautiful is better than ugly
   o Explicit is better than implicit
   o Simple is better than complex
   o Readability counts
   o Special cases aren't special enough to break the rules
   o Errors should never pass silently

?

And most importantly:

   o In the face of ambiguity, refuse the temptation to guess.
   o There should be one -- and preferably only one -- obvious way to
do it.

?

So, what's the one obvious right way to express "foo\zbar"? Is it

   "foo\zbar"

or

   "foo\\zbar"

And if it's the latter, what possible benefit is there in allowing the
former?  And if it's the former, why does Python echo the latter?

|>ouglas



More information about the Python-list mailing list