Python: replace '%' with str.format for examples & templates

Use modern/preferred string formatting for user facing scripts.
This commit is contained in:
Campbell Barton
2024-04-12 15:33:40 +10:00
parent 0bb6317035
commit 98986c6562
14 changed files with 25 additions and 26 deletions

View File

@@ -21,8 +21,9 @@ class OBJECT_OT_property_example(bpy.types.Operator):
def execute(self, context):
self.report(
{'INFO'}, 'F: %.2f B: %s S: %r' %
(self.my_float, self.my_bool, self.my_string)
{'INFO'}, "F: {:.2f} B: {:s} S: {!r}".format(
self.my_float, self.my_bool, self.my_string,
)
)
print('My float:', self.my_float)
print('My bool:', self.my_bool)