Nick Coghlan wrote: > > On 13 Jan 2014 01:22, "Kristján Valur Jónsson" <kristjan at ccpgames.com > <mailto:kristjan at ccpgames.com>> wrote: > > > Well, my suggestion would that we _should_ make it work, by having > the %s format specifyer on bytes objects mean: str(arg).encode('ascii', > 'strict') > > It is not explicit, it is implicit - whether or not the resulting string > assumes ASCII compatibility or not depends on whether you pass a binary > value (no assumption) or a string value (assumes ASCII compatibility). How do you make that out? As far as I can see, Kristjan's proposal will *always* call str() on the argument of a %s format, regardless of its type. The *result* of that str() is then *required* (not assumed) to be encodable as ascii. I don't see any type-dependent changes in behaviour here. Interpolating a bytes object as-is, without a conversion to text, should be done by a different format specifier, such as %b. All text/bytes conversions are then explicit: if you write %s, then you're encoding something as ascii, but if you write %b, you're just inserting something that's already binary. -- Greg
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4