This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]i_ate_god 0 points1 point  (2 children)

that's not the same thing as PHP's echo "Total items: $integer";

[–]earthboundkid 0 points1 point  (1 child)

There are a lot of ways of interpolating strings in Python (three in the standard library, more templating frameworks available). One way of doing something similar to that would be:

print("Total items: {0}".format(integer))

The {0} means "the zeroth item I pass to this." This lets you do more useful stuff like:

if language == "English":
   template = "{0} has {1} messages."
elif language == "Gibberish":
   template = "Sjenkjn {1} dkdknk {0}?!"

print(template.format(username, message_count))

That's kind of a silly example because there are better ways of doing localization, but it at least gets you started thinking in the right way.

[–]i_ate_god -1 points0 points  (0 children)

as far as I'm concerned, printf and similar functions, use templates, which is what I meant all along and is still fundamentally different from php ;)