Message395064
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 |
|
Date |
User |
Action |
Args |
2021-06-04 04:21:26 | Nicholas Willhite | set | recipients:
+ Nicholas Willhite, vstinner, ezio.melotti |
2021-06-04 04:21:26 | Nicholas Willhite | set | messageid: <1622780486.03.0.720343987459.issue44308@roundup.psfhosted.org> |
2021-06-04 04:21:26 | Nicholas Willhite | link | issue44308 messages |
2021-06-04 04:21:25 | Nicholas Willhite | create | |
|