[Tutor] String formatting question.
Blockheads Oi Oi
breamoreboy at yahoo.co.uk
Wed Mar 30 00:38:21 CEST 2011
On 29/03/2011 20:41, Prasad, Ramit wrote:
> Is there a difference (or preference) between using the following?
> "%s %d" % (var,num)
> VERSUS
> "{0} {1}".format(var,num)
>
>
> Ramit
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
From Python 2.7.1 docs at
http://docs.python.org/tutorial/inputoutput.html "Since str.format() is
quite new, a lot of Python code still uses the % operator. However,
because this old style of formatting will eventually be removed from the
language, str.format() should generally be used.".
More information about the Tutor
mailing list