You can also map a dictionary of values to the format string:

>>> num = 99
>>> obj = 'red balloons'
>>> print '%(a)d %(b)s' % {'a': num, 'b': obj}
99 red baloons

Keith

On Aug 22, 12:28 am, "Ronny Haryanto" <[EMAIL PROTECTED]> wrote:
> On Thu, Aug 21, 2008 at 10:41 PM, Joost Cassee <[EMAIL PROTECTED]> wrote:
> > Just a quick question to set my head right for future Django
> > contributions. Why is "%s/" % var better than var + '/'? I can think
> > of some reasons: 1) consistency with other code, 2) certainty of
> > string concatenation. But is the second expression not much faster?
> > (This is an honest question, no criticism or anything.)
>
> It's also discussed in Recipe 3.5, "Combining Strings", in the Python 
> Cookbook:
>
> http://books.google.com/books?id=yhfdQgq8JF4C&pg=PA73&lpg=PA73&dq=pyt...
>
> Ronny
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to