New Python 3.0 string formatting - really necessary?

excord80 excord80 at gmail.com
Fri Dec 19 14:43:12 EST 2008


On Dec 19, 11:01 am, walterbyrd <walterb... at iname.com> wrote:
>
> To me, it seems that this:
>
> print "%s=%d" % ('this',99)
>
> Is much easier, and faster, to type, and is also easier to read and
> understand. [snip]
>
> This (if it's right) is much longer, and requires more special
> characters.
>
> print( "{0}={1}".format('this',99))
>

Yeah, I like the old way better too. It's got this nice elegant
simplicity to it (using the percent sign for not only the things
inside the string, but also to separate it from the tuple that
follows). Also, I like having only *one* special symbol (`%') to worry
about in my strings instead of two (`{' and `}').

But, Python is Python. So I'll keep using the old way until they
deprecate it, and then just get used to the new way. One reason I use
Python is because I really *don't* have the time or inclination to
question every little design decision and argue about alternatives. If
you want to tweak the language to suit your personal tastes, you might
prefer Perl 6.



More information about the Python-list mailing list