Keyword argument parsing in error in 2.0?

Steve Holden sholden at holdenweb.com
Fri Jun 8 17:53:06 EDT 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.beer", "l.drinker", ["count(distinct s.bar)",
"nbars"]],
        FROM=[["likes", "l"], ["serves", "s"]],
        WHERE="l.beer=s.beer",
        REST="group by l.beer, l.drinker"),
        c.SELECT("distinct beer, drinker, 0 as nbars",
        FROM="likes",
        WHERE="beer not in (%s)" %
            c.SELECT("beer",
                FROM="serves")),
                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 "alltest.py", 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"),
        REST="Ignore3")

This runs fine, printing

STARTING
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?

regards
 Steve







More information about the Python-list mailing list