[Python-ideas] Briefer string format

Ryan Gonzalez rymg19 at gmail.com
Wed Jul 22 02:44:32 CEST 2015



On July 21, 2015 7:30:02 PM CDT, Chris Angelico <rosuav at gmail.com> wrote:
>On Wed, Jul 22, 2015 at 10:28 AM, Ryan Gonzalez <rymg19 at gmail.com>
>wrote:
>> Pretty sure I'm going to be odd one out, here...
>>
>> I don't like most of Ruby, but, after using Crystal and CoffeeScript,
>I have
>> fallen in love with #{}. It gives the appearance of a real
>expression, not
>> just a format placeholder. Like:
>>
>> f'a#{name}b'
>
>That's what I'm talking about. It's not a placeholder. It's not a
>duplicated name that references a keyword argument at the end of the
>expression. It's an actual expression.
>

I'm referring to the syntax, though. It makes it visually distinct from normal format string placeholders.

Also: plain format strings are a *pain* to escape in code generators, e.g.:

print('int main() {{ return 0+{name}; }}'.format(name))

Stupid double brackets. That is why I still use % formatting.

#{} isn't a common expression to ever use. I have never actually printed a string that contains #{} (except when using interpolation in CoffeeScript/Crystal).

>ChrisA
>_______________________________________________
>Python-ideas mailing list
>Python-ideas at python.org
>https://mail.python.org/mailman/listinfo/python-ideas
>Code of Conduct: http://python.org/psf/codeofconduct/

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.
Currently listening to: Deep Drive by Yoko Shimomura (KH 2.5)


More information about the Python-ideas mailing list