This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author zuo
Recipients zuo
Date 2010-12-12.04:29:59
SpamBayes Score 4.2230135e-09
Marked as misclassified No
Message-id <1292128202.55.0.0300342497244.issue10682@psf.upfronthosting.co.za>
In-reply-to
Content
Let examples speak:

    def x(a, z): pass      # this is ok
    def x(a, z,): pass     # this is ok
    def x(a, *, z): pass   # this is ok in Py3k
    def x(a, *, z,): pass  # but this causes SyntaxError (!)

    def x(a, *args): pass      # this is ok
    def x(a, *args,): pass     # but this causes SyntaxError
    def x(a, **kwargs): pass   # this is ok
    def x(a, **kwargs,): pass  # but this causes SyntaxError
    def x(a, *args, z): pass   # this is ok in Py3k
    def x(a, *args, z,): pass  # but this causes SyntaxError (!)

And similarly -- calls:

    def x(*args, **kwargs): pass
    x(1, *(2,3,4))        # this is ok
    x(1, *(2,3,4),)       # but this causes SyntaxError
    x(1, **{5: 6})        # this is ok
    x(1, **{5: 6},)       # but this causes SyntaxError
    x(1, 2, 3, 4, z=5)    # this is ok
    x(1, *(2,3,4), z=5)   # this is ok in Py2.6+ and Py3k
    x(1, *(2,3,4), z=5,)  # but this causes SyntaxError (!)

Similar problem was discussed years ago as a docs bug -- see: issue798652, but -- as inconsistent with intuition and a general Python rule that trailing commas are ok in argument lists and sequence literals (except empty ones) -- it seems to be rather a language syntax definition issue.

Now, after introducing new syntax possibilities in Py2.6 and especially Py3k (see the examples above), the issue is even much more painful.

Also, please consider that Py3k's function annotations encourage to format argument list in one-argument-per-line-manner:

    def my_func(
        spam:"Very tasty and nutritious piece of food",
        ham:"For experts only",
        *more_spam:"Not less tasty and not less nutritious!",
        spammish:"Nobody expects this!"='Inquisition',
    ):
        ...
History
Date User Action Args
2010-12-12 04:30:02zuosetrecipients: + zuo
2010-12-12 04:30:02zuosetmessageid: <1292128202.55.0.0300342497244.issue10682@psf.upfronthosting.co.za>
2010-12-12 04:29:59zuolinkissue10682 messages
2010-12-12 04:29:59zuocreate