[sf-lug] [PYCLASS] Still on exercise 2.1

Charles-Henri Gros chgros at coverity.com
Sun Oct 5 22:34:39 PDT 2008

Christian Einfeldt wrote:
> hi,
> On Sun, Oct 5, 2008 at 9:54 PM, Charles-Henri Gros <chgros at coverity.com
> <mailto:chgros at coverity.com>> wrote:
> thx for this:
>     %d means: there will be a decimal value to print
>     %02d means: there will be a decimal value to print; print 2 digits (this
>     is all a bit too complicated to explain in detail in an e-mail)
>     The next '%' announces the arguments, i.e. the values referred to above
>     ( a, b ) [where a is (secs/MIN) and b is (secs%MIN) specifies the values
>     The colon is just printed verbatim.
>     The (a,b) structure is called a "tuple", it represents multiple values.
>     For instance to print 3 integers you could use
>     print "integer 1:%d; integer 2:%d; integer 3:%d" % (11, 12, 13)
> It almost looks as if this is a definitional statement or an assignment
> statement in which you are assigning the values of 11, 12, and 13 to
> integer 1, integer 2, and integer 3.
> Coincidentally, I am wondering why you left a space after "integer"  I
> am guessing that is because integer is a keyword in Python?

No, this is all just for printing. There's no assignment here. Even if
"integer" was a keyword (I don't think it is), the fact that it's within
quotes means this is all just text that we want to manipulate (in this
case, we're printing it).

It's just that, through "%d", the text in quotes references the values
in the tuple.


More information about the sf-lug mailing list