9 ms·
I really like the format strings in Python 3.6: https://docs.python.org/3/whatsnew/3.6.html#whatsnew36-pep498 https://docs.python.org/3/whatsnew/3.6.html#whatsn
by morinted 9y ago
I really like the format strings in Python 3.6: https://docs.python.org/3/whatsnew/3.6.html#whatsnew36-pep498 https://docs.python.org/3/whatsnew/3.6.html#whatsnew36-pep49...
Seems that this set of slides (which were very informative!) is for up to 3.5
- lottin 9y agoHow many format strings does Python have already?
- baq 9y agohttps://pyformat.info/ https://pyformat.info/ should know, ask it
- Sir_Cmpwn 9y agoThis link does not mention f-strings, the feature in question. The answer is there are 3 ways to format a string: %, .format, and f-strings.
- deathanatos 9y ago.format() and format string literals essentially share the same syntax, so I don't really think it's fair to bracket them out separately. You could sort of pull a retcon and say that .format() is the dynamic form of f'' literals. Having used the equivalent feature in JavaScript, this stuff is super handy. It also makes "printf" a lot nicer: print('I have {count} {color} {object}'.format(count=count, color=color, object=object)) print('I have {} {} {}'.format(count, color, object)) print(f'I have {count} {color} {object}') % had real issues, so I'm quite glad .format() came along.