[Python-Dev] Can we please have a better dict interpolation
syntax?
Greg Ewing
greg at cosc.canterbury.ac.nz
Thu Oct 23 19:48:55 EDT 2003
Skip Montanaro <skip at pobox.com>:
> I think we've been around the block on this one a few times. While %{foo}
> might be a convenient shorthand for %(foo)s, I don't think it saves enough
> space (one character) or stands out that much more ("{...}" instead of
> "(...)s") to make the addition worthwhile.
I disagree strongly -- I think it *does* stand out more clearly. The
"s" on the end of "%(name)s" too easily gets mixed up with other
alphanumeric stuff nearby. If it were just "%(name)" *without* the
trailing "s" it wouldn't be nearly as bad, but unfortunately it can't
be left off and remain backwards compatible.
> What if lid1 is a float which you want to display with two digits
> past the decimal point?
Then I would use the existing construct -- I'm not suggesting that
it be removed.
> in which case you also have the problem of having two almost identical
> ways to do dictionary interpolation.
I don't see that as a big problem. To my mind, practicality beats
purity here -- "%(name)s" is too awkward to be practical for routine
use.
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
greg at cosc.canterbury.ac.nz +--------------------------------------+
More information about the Python-Dev
mailing list