gah! I hate the new string syntax

Tim Roberts timr at probo.com
Fri Mar 2 02:33:59 EST 2001


"Sean 'Shaleh' Perry" <shaleh at valinux.com> wrote:

>return ";".join(["%s=%s" % (k, params[k]) for k in params.keys()])
>
>every day python seems to be moving closer to the line noise aspect of
>coding.

But join is really the only one of the string methods that comes out so
awkwardly.  The rest of them are quite sensible.  And, at least for now,
you do still have the traditional string.join alternative.

Wouldn't your code be slightly quicker if you used items() instead of
looking up the individual keys:

return ";".join(["%s=%s" % it for it in params.items()])
--
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.



More information about the Python-list mailing list