On 02/15/18 02:56, Peter Otten wrote:
>> class FSTR(str):
>> def __call__(self, *args):
>> return self.format(*args)
>>
>> And here is how it could be used.
>>
>> s = FSTR("ABC {1} {0} {2[x]}")
>
> This can be simplified to
>
> s = "ABC {1} {0} {2[x]}".format
Hmm. Hadn't thought of that.
>> print(s(1, 2, dict(x=3)))
>>
>> Too bad that it is too late to assign f'' to that function.
>
> I must be missing something. How would you simplify or improve the
> readability of the above with your version of f"..."?
s = f"ABC {1} {0} {2[x]}"
--
D'Arcy J.M. Cain
Vybe Networks Inc.
http://www.VybeNetworks.com/
IM:[email protected] VoIP: sip:[email protected]
--
https://mail.python.org/mailman/listinfo/python-list