Eric V. Smith added the comment:

So it sounds like the use case is (as Glyph said in msg180432):

- Provide a transition for users of 2.7's of str %-formatting into a style 
that's compatible with both str in 2.7 and bytes in 3.4.

In that case the only options I see are to implement __mod__ or .format for 
bytes in 3.4. I'd of course prefer to use .format, although __mod__ would 
probably make the transition easier (no need to move to .format first). It 
would probably also make the implementation easier, since there's so much less 
code in str.__mod__. But let's assume we're using .format [1].

Given the restricted use case, and assuming we using .format, the 
implementation would not need to support:
- Types other than bytes, int, float.
- Subclasses of these types with custom formatting.
- !s, !r, or !a (none of the ! conversions). [2]

But it would support all of the specifiers for formatting strs (except now for 
bytes), floats, and ints.

I haven't looked through the str.format or {str,int,float}.__format__ code 
since the PEP 393 work, so I'm not really sure if we could stringlib-ify the 
code again, or if it would just be easier to reimplement it as separate 
bytes-only code.

[1] It's open for debate whether .format or .__mod__ is preferable.
[2] Since %-formatting supports %r and %s, this point is arguable.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue3982>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to