[Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5
Steven D'Aprano
steve at pearwood.info
Sun Jan 12 18:36:57 CET 2014
More information about the Python-Dev mailing list
Sun Jan 12 18:36:57 CET 2014
- Previous message: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5
- Next message: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sun, Jan 12, 2014 at 11:16:37PM +1000, Nick Coghlan wrote:
> > content = '\n'.join([
> > 'header',
> > 'part 2 %.3f' % number,
> > binary_image_data.decode('latin-1'),
> > utf16_string.encode('utf-16be').decode('latin-1'),
> > 'trailer']).encode('latin-1')
>
> Why are you proposing to do the *join* in text space?
In defence of that, doing the join as text may be useful if you have
additional text processing that you want to do after assembling the
whole string, but before calling encode.
Even if you intend to encode to bytes at the end, you might prefer to
work in the text domain right until just before the end:
- no need for b' prefixes;
- indexing a string returns a 1-char string, not an int;
- can use the full range of % formatting, etc.
--
Steven
- Previous message: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5
- Next message: [Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list