Keyword argument parsing in error in 2.0?

Steve Holden sholden at
Fri Jun 8 23:53:06 CEST 2001

I'm working on a SQL abstraction layer, using methods to generate SQL
appropriate to a particular database back-end. This has involved using
keyword arguments to many of the methods. As a catchall (to avoid having to
handle too much SQL syntax) many methods have a REST keyword argument, which
is appended to the generated statement. The 2.0 compiler is complaining
about the following statement:

c.UNION(c.SELECT(["", "l.drinker", ["count(distinct",
        FROM=[["likes", "l"], ["serves", "s"]],
        REST="group by, l.drinker"),
        c.SELECT("distinct beer, drinker, 0 as nbars",
        WHERE="beer not in (%s)" %
                REST="order by 3 desc")

This validates fine in PythonWin, but when the module containing it is
executed I get:

Traceback (most recent call last):
  File "", line 396, in ?
    REST="order by 3 desc"),
TypeError: keyword parameter redefined: REST

The implication is clearly that the system is seeing two definitions of the
same keyword argument, but I have tried to analyze the statement carefully
and it seems to me that the different REST arguments are being provided to
different calls.

Just to check, I tried running the following program:

def a(x, y, z, REST="NothingA"):
    return "%s %s %s %s" % (x, y, z, REST)

def b(x, y, z, REST="NothingB"):
    return "%s %s %s %s" % (x, y, z, REST)

print "STARTING"

print a("a",
        b("m", "n", "o", REST="Ignore1"),
        a("s", "t", "u", REST="Ignore2"),

This runs fine, printing

a m n o Ignore1 s t u Ignore2 Ignore3

Is this a bug, or can I simply not see my error for looking too hard?


More information about the Python-list mailing list