-
-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chapter 9 String Interpolation #195
Comments
How many should we show. In my opinion we should be moving toward the future. In fact my preferred method is to teach students f-strings
The % operator is still good/interesting to show students as it maps to C/C++/Java but it is definitely not mainstream Python in 2021. |
Very fair point. I have updated my Issue. |
I am working on this issue |
I think students should be exposed to all of the various string interpolation types so that they understand what they see when they run across code. But I think we should isolate .format and the old printf style formats to a section and then use fstrings consistently throughout. |
I have been convinced that @bnmnetp is right about this. |
The PEP standards include two methods for string interpolation. See https://www.python.org/dev/peps/pep-3101/
Python currently provides two methods of string interpolation:
The '%' operator for strings.
"My name is {0}".format('Fred')
"My name is %s" % ('Fred')
But perhaps we should be presenting the simpler syntax of f-strings as described in https://www.python.org/dev/peps/pep-0498/ as recommended by @bnmnetp below?
The text was updated successfully, but these errors were encountered: