Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #86180
| Return-Path | <python-python-list@m.gmane.org> |
|---|---|
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'correct.': 0.07; 'incompatible': 0.07; 'string': 0.09; 'escape': 0.09; 'inherited': 0.09; 'literal': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:string': 0.09; 'unrecognized': 0.09; 'python': 0.11; 'language,': 0.12; 'windows': 0.15; 'backslash': 0.16; 'character.': 0.16; 'finney': 0.16; 'formatted': 0.16; 'henry': 0.16; 'literals': 0.16; 'literals.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'unambiguous': 0.16; 'language': 0.16; 'programming': 0.22; 'header:User-Agent:1': 0.23; 'error': 0.23; 'documented': 0.24; 'refers': 0.24; 'sort': 0.25; 'right.': 0.26; 'header:X -Complaints-To:1': 0.27; 'chris': 0.29; 'character': 0.29; "doesn't": 0.30; 'writes:': 0.31; 'languages': 0.32; 'text': 0.33; 'url:python': 0.33; 'reader': 0.33; 'but': 0.35; 'there': 0.35; 'really': 0.36; 'url:org': 0.36; 'ben': 0.38; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'anything': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'even': 0.60; 'url:3': 0.61; "you're": 0.61; 'such': 0.63; 'needing': 0.65; 'believe': 0.68; 'anything.': 0.68; 'received:125': 0.84; 'url:reference': 0.84; '\xe2\x80\x9cthe': 0.91; 'have.': 0.93 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Ben Finney <ben+python@benfinney.id.au> |
| Subject | Re: Unrecognized backslash escapes in string literals |
| Date | Mon, 23 Feb 2015 13:41:26 +1100 |
| References | <CAPTjJmqx3s1a0LL4RLgVB1PsOfyF9ryy6nwHwOwrQs1Zx2Hd-Q@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 8bit |
| X-Gmane-NNTP-Posting-Host | jigong.madmonks.org |
| X-Public-Key-ID | 0xAC128405 |
| X-Public-Key-Fingerprint | 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 |
| X-Public-Key-URL | http://www.benfinney.id.au/contact/bfinney-pubkey.asc |
| X-Post-From | Ben Finney <bignose+hates-spam@benfinney.id.au> |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) |
| Cancel-Lock | sha1:6OR3goH+ccYeccZsNND2wqyzw50= |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.19043.1424659276.18130.python-list@python.org> (permalink) |
| Lines | 37 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1424659276 news.xs4all.nl 2833 [2001:888:2000:d::a6]:36747 |
| X-Complaints-To | abuse@xs4all.nl |
| Path | csiph.com!usenet.pasdenom.info!bete-des-vosges.org!feed.ac-versailles.fr!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
| Xref | csiph.com comp.lang.python:86180 |
Show key headers only | View raw
Chris Angelico <rosuav@gmail.com> writes: > In Python, unrecognized escape sequences are treated literally, > without (as far as I can tell) any sort of warning or anything. Right. Text strings literals are documented to work that way <URL:https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str>, which refers the reader to the language reference <URL:https://docs.python.org/3/reference/lexical_analysis.html#strings>. > Why is it that Python interprets them this way, and doesn't even give > a warning? Because the interpretation of those literals is unambiguous and correct. It's unfortunate that MS Windows inherited the incompatible “backslash is a path separator”, long after backslash was already established in many programming languages as the escape character. > Is there a way to enable such warnings/errors? A warning or error for a correctly formatted literal with an unambiguous meaning would be an up-Pythonic thing to have. I can see the motivation, but really the best solution is to learn that the backslash is an escape character in Python text string literals. This has the advantage that it's the same escape character used for text string literals in virtually every other programming language, so you're not needing to learn anything unusual. -- \ “The deepest sin against the human mind is to believe things | `\ without evidence.” —Thomas Henry Huxley, _Evolution and | _o__) Ethics_, 1893 | Ben Finney
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Unrecognized backslash escapes in string literals Ben Finney <ben+python@benfinney.id.au> - 2015-02-23 13:41 +1100
csiph-web