On 11.06.2013 20:36, Chris Angelico wrote:
On Wed, Jun 12, 2013 at 4:16 AM, M.-A. Lemburg <mal@egenix.com> wrote:
How would you add a new escape character in a backwards compatible way ?
Adding new escape characters is not easy, since Python defaults to passing them through as-is, e.g. '\e' == '\\e'.
My understanding of [1] is that the feature of keeping them unchanged is meant to be a debugging aid, not something you depend on. Use of unescaped backslashes in non-raw string literals is already dangerous to editing (if someone changes your Windows path name to c:\testing, your code is broken). If a new version breaks someone's non-raw literal "c:\everything", it was already broken.
[1] http://docs.python.org/3/reference/lexical_analysis.html#literals
I'm not saying that it's useful to rely on Python's behavior, only that any such change has the potential to break perfectly working code. The last time we changed the escape code was for the introduction of Unicode string literals. That was 13 years ago. And we carefully checked what other languages were using for Unicode at the time. Given that \e only saves you two key strokes (\033 and \x1b are the usual ways to write ESC in ASCII strings), I think the ratio between usefulness and potential breakage is not in favor of an addition. BTW: pylint detects such unsupported escape codes: http://docs.pylint.org/features.html?highlight=w1401#string-constant-checker -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jun 11 2013)
Python Projects, Consulting and Support ... http://www.egenix.com/ mxODBC.Zope/Plone.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
2013-07-01: EuroPython 2013, Florence, Italy ... 20 days to go 2013-07-16: Python Meeting Duesseldorf ... 35 days to go ::::: Try our mxODBC.Connect Python Database Interface for free ! :::::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/