
On 7/25/2015 3:55 AM, Ben Finney wrote:
Guido van Rossum <guido@python.org> writes:
On Fri, Jul 24, 2015 at 10:27 PM, Ben Finney wrote:
Steven D'Aprano wrote:
I don't think I want this behaviour:
f'{spam}' '{eggs}' => format(spam) + '{eggs}' […]
>>> 'foo\abar' r'lorem\tipsum' 'wibble\bwobble' 'foo\x07barlorem\\tipsumwibble\x08wobble'
>>> type(b'abc' 'def' b'ghi') File "<stdin>", line 1 SyntaxError: cannot mix bytes and nonbytes literals
[…] Is the proposed ‘f’ prefix, on a fragment in implicit concatenation, meant to have behaviour analogous to the ‘r’ prefix or the ‘b’ prefix, or something else? What's the argument in favour of that choice?
It *must* work like r'' does. Implicit concatenation must be thought of as letting each string do its thing and then concatenating using '+', just optimized if possible. The error for b'' comes out because the '+' refuses b'' + ''.
That makes sense, and is nicely consistent (‘f’, ‘r’, and ‘b’ all apply only to the one fragment, and then concatenation rules apply). Thanks.
Yes, I think that's the only interpretation that makes sense.
I find it a sign of the times that even this simple argument goes on and on forever. Please stop the thread until Eric has had the time to write up a PEP.
I found this discussion helpful in knowing the intent, and what people's existing expectations are.
Hopefully you found it helpful too, Eric! In either case, I look forward to your PEP.
In trying to understand the issues for a PEP, I'm working on a sample implementation. There, I've just disallowed concatentation entirely. Compared to all of the other issues, it's really insignificant. I'll put it back at some point. Eric.