On Fri, Jun 14, 2013 at 7:01 PM, Jim Mooney <[email protected]> wrote:
> On 14 June 2013 08:23, Dotan Cohen <[email protected]> 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
>
Thank you. So would it be clear if I were to say "I prefer
printf-style formatting over the format method."?
> put python string expression or python string method in that great
> teaching tool, Google.
>
Thank you. I had in fact Googled for "Python string" and "Python
string variable replacement names" but I didn't get much further than
the fine Python manual which doesn't clearly name the second method. I
suppose that knowing what to Google for is 90% of the way to an
answer!
> 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 ;')
>
Oh? Which book is that? I've so far been learning by writing small
applications here and there. I have been meaning to go through Learn
Python The Hard Way for the longest time.
--
Dotan Cohen
http://gibberish.co.il
http://what-is-what.com
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor