Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In function call, keyword arguments could follow *args #47723

Closed
amauryfa opened this issue Jul 31, 2008 · 17 comments
Closed

In function call, keyword arguments could follow *args #47723

amauryfa opened this issue Jul 31, 2008 · 17 comments
Assignees

Comments

@amauryfa
Copy link
Member

BPO 3473
Nosy @warsaw, @birkenfeld, @rhettinger, @terryjreedy, @mjpieters, @jcea, @amauryfa, @ncoghlan, @benjaminp
Files
  • kwargs30.patch
  • kwargs26.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/amauryfa'
    closed_at = <Date 2008-08-19.19:53:03.394>
    created_at = <Date 2008-07-31.01:16:30.124>
    labels = []
    title = 'In function call, keyword arguments could follow *args'
    updated_at = <Date 2014-08-28.04:07:25.212>
    user = 'https://github.com/amauryfa'

    bugs.python.org fields:

    activity = <Date 2014-08-28.04:07:25.212>
    actor = 'python-dev'
    assignee = 'amaury.forgeotdarc'
    closed = True
    closed_date = <Date 2008-08-19.19:53:03.394>
    closer = 'benjamin.peterson'
    components = []
    creation = <Date 2008-07-31.01:16:30.124>
    creator = 'amaury.forgeotdarc'
    dependencies = []
    files = ['11010', '11011']
    hgrepos = []
    issue_num = 3473
    keywords = ['patch']
    message_count = 17.0
    messages = ['70449', '70451', '70485', '70499', '70502', '70510', '70597', '71094', '71198', '71293', '71471', '71473', '71481', '71486', '72485', '225968', '226009']
    nosy_count = 10.0
    nosy_names = ['barry', 'georg.brandl', 'rhettinger', 'terry.reedy', 'mjpieters', 'jcea', 'amaury.forgeotdarc', 'ncoghlan', 'benjamin.peterson', 'python-dev']
    pr_nums = []
    priority = 'normal'
    resolution = 'accepted'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue3473'
    versions = ['Python 3.0']

    @amauryfa
    Copy link
    Member Author

    functions with keyword-only arguments have this form:
    def f(x, *args, y):
    pass
    parameters can appear after the *arg, they are required to be passed by
    keyword.

    It would be more consistent to allow this function call:
    f(X, *ARGS, y=Y)
    This is invalid syntax, *ARGS is required to be at the end of the
    arguments, together with an eventual **KWARGS. This restriction should
    be lifted.

    See the use case in
    http://mail.python.org/pipermail/python-3000/2008-July/014437.html

    @amauryfa amauryfa self-assigned this Jul 31, 2008
    @amauryfa
    Copy link
    Member Author

    Should this apply to 2.6 as well? See r65321, I find the last line
    easier to read when arguments are in this order.

        def grouper(n, iterable, fillvalue=None):
            args = [iter(iterable)] * n
            return izip_longest(*args, fillvalue=fillvalue)

    On the cons side, keyword-only arguments don't exist in 2.6, so the
    consistency with function definition syntax does not apply.

    @rhettinger
    Copy link
    Contributor

    +1 for applying to 2.6.

    izip_longest() is a perfect example of where it's important.

    @amauryfa
    Copy link
    Member Author

    Patches for both versions are attached.

    @benjaminp
    Copy link
    Contributor

    The patches look good to me.

    @ncoghlan
    Copy link
    Contributor

    I'll have a look at this in the next day or two.

    @amauryfa
    Copy link
    Member Author

    amauryfa commented Aug 1, 2008

    I will not have internet access for the next week.
    Raymond, would you take care of this issue?

    @amauryfa amauryfa assigned rhettinger and unassigned amauryfa Aug 1, 2008
    @terryjreedy
    Copy link
    Member

    Another use case: upon reading A.Baxter's Porting to 3 talk, I realized,
    slightly generalizing from his example, that
    print(s.join(map(str,it))) == print(*it,sep=s) -- or would, except that
    it currently has to be written non-intuitively as print(sep=s,*it),
    which I might not have tried except for knowing about this issue.

    Given that many have problems with .join and that most uses are to
    produce immediate output not otherwise processed, I think having the
    replacement work in the way many would expect would be a win.
    So I hope this makes the next beta.

    @birkenfeld
    Copy link
    Member

    Ping!

    @amauryfa
    Copy link
    Member Author

    Barry, is it still time for this to be included in 2.6b3?
    Guido already approved the idea:
    http://mail.python.org/pipermail/python-3000/2008-July/014506.html

    @amauryfa amauryfa assigned amauryfa and unassigned rhettinger Aug 17, 2008
    @warsaw
    Copy link
    Member

    warsaw commented Aug 19, 2008

    Guido's approved it, so please go ahead and add it before beta 3.

    @benjaminp
    Copy link
    Contributor

    Applied for 2.6 in r65872.

    @benjaminp
    Copy link
    Contributor

    Done for py3k in r65877.

    @benjaminp
    Copy link
    Contributor

    Now test_compiler is breaking for us because the compiler package can't
    handle the change.

    @amauryfa
    Copy link
    Member Author

    amauryfa commented Sep 4, 2008

    The compiler package was fixed some time ago with r65891

    @mjpieters
    Copy link
    Mannequin

    mjpieters mannequin commented Aug 27, 2014

    The documentation change in this patch introduced a bug in the Call grammar:

    | "" expression ["," "" expression] ["," "**" expression]

    instead of

    | "*" expression ["," keyword_arguments] ["," "**" expression]

    giving the impression that *expression is allowed twice.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Aug 28, 2014

    New changeset 3ae399c6ecf6 by Benjamin Peterson in branch '2.7':
    correct call grammar error (bpo-3473)
    http://hg.python.org/cpython/rev/3ae399c6ecf6

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    None yet
    Projects
    None yet
    Development

    No branches or pull requests

    7 participants