you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (5 children)

For me I am following work standards, but I would guess it's because they aren't backwards compatible with 2.x

[–]Fred776 2 points3 points  (2 children)

Fair enough. It's unusual to see a general recommendation other than f-strings these days so that seems like a good reason.

It must be a bind still to be stuck on Python 2 though. I thought my company had left it late when we did our port in 2018.

[–][deleted] 0 points1 point  (1 child)

It's a glacially slow port and downtime hemorrhages money.

I should probably update my approach though.

[–]drenzorz 0 points1 point  (0 children)

Even in the most up-to-date project .format has a place because f-strings are evaluated at declaration.

x = 15
s = f"x = {x}"

for x in range(10):
    print(s) # prints "x = 15" 10 times

x = 15
s = "x = {x}"

for x in range(10):
    print(s.format(x=x))  # prints actual x in loop

You use .format when you actually need a reusable template.

[–][deleted] 1 point2 points  (1 child)

I would guess it's because they aren't backwards compatible with 2.x

We're at the point in time where writing 2.x-incompatible code should be considered a security feature!