Well, according to the python beginners book; "Dive Into Python" [1],
string formatting is less error prone as it also does type coercion
whereas string concatenation only works when all objects are already
strings. When it's possible that a user will be passing in parts of
the concatenation, I'd rather be using formatting for that reason
alone.

I had thought that I read from that same source that formatting is
faster than concatenation (and that's why I checked there before
responding), but I don't see that mentioned. Not sure where I got that
idea or if its even true.

[1]: http://diveintopython.org/native_data_types/formatting_strings.html

On Thu, Aug 21, 2008 at 11:41 AM, Joost Cassee <[EMAIL PROTECTED]> wrote:
>
> Hi all,
>
> 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.)
>
> Regards,
>
> Joost
> >
>



-- 
----
Waylan Limberg
[EMAIL PROTECTED]

--~--~---------~--~----~------------~-------~--~----~
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