[Python-ideas] Binary f-strings

Eric V. Smith eric at trueblade.com
Sat Oct 3 21:18:06 CEST 2015


On 10/03/2015 12:20 PM, Steve Dower wrote:
> "Something else that's neat with this: you could use the struct module
> for more complex subsections of a binary protocol"
> 
> Personally, if binary f-strings did struct packing by default, I'd want
> to use them all the time.

That appeals to me, too. There are a number of practical problems that
would need to be worked out. We can argue those later :)

I guess it comes down to: what would the commonest use case for
fb-strings be?

> Practically, if they aren't equivalent to removing the b and encoding
> the resulting f-string, I expect we'll regularly hit confusion and
> misunderstanding.

This is one of my two big concerns. If we do something other than remove
'b' and encode, then we've got two similar looking things that have
vastly different implementations. But maybe struct.pack or %-formatting
are so compelling that it's worth breaking the equivalence.

My other concern is non-ascii chars inside the braces in an fb-string.

Eric.





More information about the Python-ideas mailing list