Search code examples
pythonpython-2.7linguistics

What's the end on 'print "%d" % (5)' called?


A linguistic question I guess, but what's the (5) called in the code print "%d" % (5) ?

I call the %d an integer representation, but I'm not sure what to call the stuff it actually represents, regardless of it being a number, a variable, a calculation or w/e. Is it called an argument?

I'm wondering because I'm making comments for an assignment where I'm calculating stuff in the parenthesis instead of making a new variable, calculating the variable and inserting the variable like x = 5;print "%d" % (x)


Solution

  • The documentation calls it "values":

    If format requires a single argument, values may be a single non-tuple object.

    The %d is called "conversion specifications". Each of them takes one or more "arguments" from the elements in "values".

    %d takes one argument, %*d takes two, for example. All arguments make up "values".

    That would mean 5 is the argument to %d while (5) is the "values" for the whole format.