Python 3's F-Strings: An Improved String Formatting Syntax
1–10 of 147 posts
Re: Python 3's F-Strings: An Improved String Formatting Syntax
#2Other than that, I agree, much better than % and less verbose than .format.
It's just the f" or f' that doesn't sit right with me
Re: Python 3's F-Strings: An Improved String Formatting Syntax
#3I can't say I like the f" syntax much. I think JS's backtick is better. Other than that, I agree, much better than % and less verbose than .format. It's just the f" or f' that doesn't sit right with me
Re: Python 3's F-Strings: An Improved String Formatting Syntax
#4I can't say I like the f" syntax much. I think JS's backtick is better. Other than that, I agree, much better than % and less verbose than .format. It's just the f" or f' that doesn't sit right with me
Re: Python 3's F-Strings: An Improved String Formatting Syntax
#5Re: Python 3's F-Strings: An Improved String Formatting Syntax
#6 name = 'world'
print(f'hello {name.upper()=}')
outputs: hello name.upper()='WORLD'
It's small, but very useful in debugging an issue or logging something to the console.https://docs.python.org/3/whatsnew/3.8.html#f-strings-suppor...
Re: Python 3's F-Strings: An Improved String Formatting Syntax
#7I can't say I like the f" syntax much. I think JS's backtick is better. Other than that, I agree, much better than % and less verbose than .format. It's just the f" or f' that doesn't sit right with me
Yup, especially as you often need to access dict's with foo["field"] and you get a syntax error if the f-strings is also f"". JavaScript backtick syntax doesn't lead to this extra syntactic friction.
f"{foo['field']}"
f'{foo["field"]}'
f"""{foo["field"]}"""
(I see from your carefully worded first sentence that you already knew this but still find it annoying, but I'll leave this here for any that aren't aware.)Re: Python 3's F-Strings: An Improved String Formatting Syntax
#8I can't say I like the f" syntax much. I think JS's backtick is better. Other than that, I agree, much better than % and less verbose than .format. It's just the f" or f' that doesn't sit right with me
Yup, especially as you often need to access dict's with foo["field"] and you get a syntax error if the f-strings is also f"". JavaScript backtick syntax doesn't lead to this extra syntactic friction.
Re: Python 3's F-Strings: An Improved String Formatting Syntax
#9Re: Python 3's F-Strings: An Improved String Formatting Syntax
#10I can't say I like the f" syntax much. I think JS's backtick is better. Other than that, I agree, much better than % and less verbose than .format. It's just the f" or f' that doesn't sit right with me
Yup, especially as you often need to access dict's with foo["field"] and you get a syntax error if the f-strings is also f"". JavaScript backtick syntax doesn't lead to this extra syntactic friction.