String formatting style

Michael Aye kmichael.aye at gmail.com
Tue Sep 2 20:20:40 EDT 2014


It's part of the Python tutorial for many years and common standard I'd say.
It's basic use might be cumbersome at first, but its power is great.

Things like "My name is {0[name]}".format(dict(name='Fred'))
or
"My name is {0.name}".format(open('out.txt', 'w'))
lets you template-control strings in very elaborate manners.
The most minimalistic way btw is:

"My first name is {} and my last name is {}".format(firstname, lastname)

Michael

On Tuesday, September 2, 2014 7:36:44 AM UTC-7, Juan Nunez-Iglesias wrote:
>
> I'm not convinced either, but it seems to be what the whole community is 
> moving to (I saw many instances of it at PyCon-AU), so we might as well get 
> with the program!
>
> On Tuesday, September 2, 2014, Stéfan van der Walt <ste... at sun.ac.za 
> <javascript:>> wrote:
>
>> Hi all
>>
>> What are your opinions on
>>
>> http://legacy.python.org/dev/peps/pep-3101/
>>
>> I see this is used in some PRs, and I'm not convinced of its readability.
>>
>> Stéfan
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "scikit-image" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to scikit-image+unsubscribe at googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-image/attachments/20140902/cafe59a3/attachment.html>


More information about the scikit-image mailing list