On Sun, Nov 02, 2008 at 09:45:41AM +0000, jmr wrote:
> Fujiwara - why do you want these changes added? There are plenty of other
> error messages in these files, following the same pattern and yet you do
> not change any of them. I can see the benefit of dumping out a symbol table
> for debugging purposes, but why here and nowhere else?
It's not dumping the symbol table. There are two ways to use % expandos in
python. The usual way is something like
"%s %s" % (a, b)
which maps the contents of the symbols "a" and "b" into the string at the
two "%s" locations. Thing is, if one language needs "a" before "b" and
another language needs "b" before "a", this method is useless. So there's
another way that uses a dictionary instead of a tuple:
"%(a)s %(b)s" % {"a": a, "b": b}
which does precisely what the previous one did, except that you can now
localize the string to be "%(b)s %(a)s" to reorder the strings.
Fujiwara is taking a cheap and easy way to this by using vars() -- if the
dictionary you pass to the expandos has more elements than are used, those
other elements are ignored. Thus if "a" and "b" are in the current
namespace, the previous example could be written as
"%(a)s %(b)s" % vars()
I don't like this as much as making it explicit, though. If you remove one
of the names, the error you get back is less indicative of the problem --
you get a KeyError on the missing name, rather than a NameError.
Danek
_______________________________________________
pkg-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/pkg-discuss