[Tutor] What are these two string-formatting styles called?
Jim Mooney
cybervigilante at gmail.com
Fri Jun 14 18:01:14 CEST 2013
On 14 June 2013 08:23, Dotan Cohen <dotancohen at gmail.com> wrote:
> What are these two string-formatting styles called?
> '%.3f' % x
> '{0:.3f}'.format(x)
>
The first one is a string Expression, using % as the overloaded operator
The second one is a string method, with .format() as the method for a
string object
put python string expression or python string method in that great
teaching tool, Google.
I know this since I'm reading that part of my python book right now and can
actually remember it. Although I fell asleep on the third page of
explanations of the more convoluted ways to use {}, which can get
convoluted indeed ;')
--
Jim
A noun is just a verb with the hiccups
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130614/d194315b/attachment.html>
More information about the Tutor
mailing list