On Tue, Mar 29, 2011 at 4:21 PM, Corey Richardson <kb1...@aim.com> wrote:
> On 03/29/2011 03:41 PM, Prasad, Ramit wrote: > > Is there a difference (or preference) between using the following? > > "%s %d" % (var,num) > > VERSUS > > "{0} {1}".format(var,num) > > > > > > Ramit > > If you're using Python 3, use the second one. If you're using Python 2, > you have no option but to use the first, as far as I know. Maybe Python > 2.7 has that formatting, I'm not sure. > > -- > Corey Richardson > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > you can use string{0}.format(var) in python 2.6. I use it all the time. I never use the other % method.
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor