"Luke Paireepinart" <[EMAIL PROTECTED]> wrote

>>>     'list_%i' % (i) = []
>>>
> Note, though this is pretty arbitrary  :) and only saves you 2 
> characters...
> You don't need to create a tuple if you're only packing in one 
> value.
> >>> i = 1
> >>> 'list_%i' % i

And that works for multiple values provided they are unambiguous.

"%d,%d,%d" % 1,2,3

You need the parens if the substitution values are more complex
and include operators:

"%d,%d,%d" % 1, 2, 1+2

Will give an error (adding int to string) you need the parens here:

"%d,%d,%d" % (1, 2, 1+2)

HTH,

Alan G 


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to