Open jasisz opened 10 years ago
I'm -1 on this. The "old" format is not going anywhere and it's very common in Python programs. It's also more consistent is simple cases:
>>> "%5s" % "abc"
' abc'
>>> "%5d" % 1
' 1'
>>> "{:5}".format("abc")
'abc '
>>> "{:5}".format(1)
' 1'
I don't think that it is more quirky than TypeError on the first, but not on the second line:
'%s' % (1,2,3) '%s' % [1,2,3]
which greatly confused one of my students.
Even in Python docs we can find note that: "Using the newer str.format() interface helps avoid these errors, and also provides a generally more powerful, flexible and extensible approach to formatting text." And if the tutorial was already moved to Python 3 I cannot see a reason to stick with the old style here. But of course decision is all up to you :)
In the tutorial we use old C-style formatting with % sign. I think it is worth to change that part to the "newer" string format method, mainly because it is much more similar to the Django template syntax.