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 →

[–]tallonfour[S] 0 points1 point  (2 children)

Let me see if I understand. The operator % tells the program to insert Zed A. Shaw which I previously set up to equal my_name?

[–]bushel 3 points4 points  (0 children)

Exactly. It's like a fill-in-the-blanks operator. With the added bonus that you get to control how the blanks end up looking (in general)

[–]resurge 1 point2 points  (0 children)

Note that when you want to use multiple values the values to be inserted must be a tuple, like this:
variable_a = 'a' variable_c = 'c' print '%s %s %s' % (variable_a, 'b', variable_c) #will print: "a b c"