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

"def f(*args, ): pass" does not compile #68865

Closed
Drekin mannequin opened this issue Jul 21, 2015 · 2 comments
Closed

"def f(*args, ): pass" does not compile #68865

Drekin mannequin opened this issue Jul 21, 2015 · 2 comments

Comments

@Drekin
Copy link
Mannequin

Drekin mannequin commented Jul 21, 2015

BPO 24677
Nosy @vadmium
Superseder
  • bpo-9232: Allow trailing comma in any function argument list.
  • 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 = None
    closed_at = <Date 2015-07-21.12:53:37.695>
    created_at = <Date 2015-07-21.10:43:42.612>
    labels = []
    title = '"def f(*args, ): pass" does not compile'
    updated_at = <Date 2015-07-21.12:53:37.693>
    user = 'https://bugs.python.org/Drekin'

    bugs.python.org fields:

    activity = <Date 2015-07-21.12:53:37.693>
    actor = 'martin.panter'
    assignee = 'none'
    closed = True
    closed_date = <Date 2015-07-21.12:53:37.695>
    closer = 'martin.panter'
    components = []
    creation = <Date 2015-07-21.10:43:42.612>
    creator = 'Drekin'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 24677
    keywords = []
    message_count = 2.0
    messages = ['247023', '247027']
    nosy_count = 2.0
    nosy_names = ['martin.panter', 'Drekin']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = None
    status = 'closed'
    superseder = '9232'
    type = None
    url = 'https://bugs.python.org/issue24677'
    versions = ['Python 3.5']

    @Drekin
    Copy link
    Mannequin Author

    Drekin mannequin commented Jul 21, 2015

    I think that a trailing comma in function definition should be allowed also after *.

    Current situation with definitions:
    def f(args, ): pass # SyntaxError
    def f(
    , ): pass # SyntaxError
    def f(, a, ): pass # SyntaxError
    def f(
    , a=2, ): pass # SyntaxError

    def f(a, ): pass # Ok
    def f(, ): pass # SyntaxError – this should probably stay error

    Corresponding calls:
    f(*args, ) # Ok
    f(*args, a, ) # Ok
    f(*args, a=2, ) # Ok

    f(a, ) # Ok
    f(, ) # SyntaxError – this is why the corresponding def behavior should stay

    My use case:
    def f(*,
    long = 1,
    list = 2,
    of = 3,
    kwonly = 4,
    parameters = 5,
    ):
    ...

    @vadmium
    Copy link
    Member

    vadmium commented Jul 21, 2015

    See existing bpo-9232. I agree with your use case, but apparently this is controversial.

    Playing the devil’s advocate here, the function calls involving *unpacking and a trailing comma only became valid in 3.5. I think this was a side effect of the new f(*args, *more) syntax, though I don’t know if it was intentional. It was not mentioned in PEP-448 that I can see.

    @vadmium vadmium closed this as completed Jul 21, 2015
    @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

    1 participant