This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Nicholas Willhite
Recipients Nicholas Willhite, ezio.melotti, vstinner
Date 2021-06-04.04:21:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1622780486.03.0.720343987459.issue44308@roundup.psfhosted.org>
In-reply-to
Content
I'm really sure this isn't filed correctly. I'm a total noob to this process, so feel free to redirect me. :) 

Bytes can be defined as a function, or a prefixed series. You can prefix a series with "b" and get the expected data type. You can also use the builtin functions "bytes" to get the same structure:

  bytes('foo\bar', 'utf-8') == b'foo\bar'
  True

But there's no builtin function for r'foo\bar' that gives you 'foo\\bar'.

This would be really handy for applications that accept a regular expression. If that regex was part of the source code, I'd just r'foo\bar' to get the expected string. Being able to accept something like bytes and do:

  data = b'foo\bar'
  raw_string(data)
  'foo\\bar'

would be really useful for applications that accept a regex as input. 

Is there an obvious way to do this that I'm not seeing? Has my google-foo failed me? Feels like a function that should exist in the stdlib.

Again, really sure I'm not "doing this correctly." So please direct me! :) 

Appreciative,
-Nick Willhite
History
Date User Action Args
2021-06-04 04:21:26Nicholas Willhitesetrecipients: + Nicholas Willhite, vstinner, ezio.melotti
2021-06-04 04:21:26Nicholas Willhitesetmessageid: <1622780486.03.0.720343987459.issue44308@roundup.psfhosted.org>
2021-06-04 04:21:26Nicholas Willhitelinkissue44308 messages
2021-06-04 04:21:25Nicholas Willhitecreate