Keyword argument parsing in error in 2.0?

Tim Peters tim.one at home.com
Fri Jun 8 18:24:09 EDT 2001


[Steve Holden]
> ...
> 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

If you count your parens , I think you'll discover that the indentation on
the final REST is misleading; clearer is:

        WHERE="beer not in (%s)" %
            c.SELECT("beer",
                FROM="serves")),
        REST="order by 3 desc")

and that explains why it thinks you specified REST twice:  you did <wink>.
PythonWin (or IDLE) should have shown you that when you hit ENTER on the
preceding line, though (they use the same auto-indent algorithm under the
covers, and it aligns the new line under WHERE).





More information about the Python-list mailing list