Damn right - too many times have my sprintf's ended up looking so ugly
- it was borderline bad code.

Goes to show, no matter how long you've used something, even if it's
day in day out, there's always something new to learn!

On Thu, Oct 20, 2011 at 7:52 PM, Bill Freeman <ke1g...@gmail.com> wrote:
> On Thu, Oct 20, 2011 at 2:21 PM, Tim Chase
> <django.us...@tim.thechases.com> wrote:
>> On 10/20/11 13:17, Cal Leeming [Simplicity Media Ltd] wrote:
>>>
>>> So, just out of curiosity, how many other people didn't realise you
>>> could do this:
>>>
>>>>>> print '%(language)s has %(number)03d quote types.' % \
>>>
>>> ...       {"language": "Python", "number": 2}
>>>
>>>
>>> Instead of this:
>>>
>>> print "%s has %03d" % ( "python", "2" )
>>
>> Also very useful in translations where the order of the pieces may have to
>> change, allowing the translator to put them where needed rather than
>> constraining the translator to the order in which the data is passed.
>>
>> -tkc
>
> And fantasticly useful when a given value is needed more than once
> in a string, or when you have a collection of available values and a
> passed in or chosen format string, such that some values may not
> be used at all.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to