Skip to content

Introduce keyword-only arguments for functions #127

@YannickJadoul

Description

@YannickJadoul

#106 removes an argument we decided is sort of useless. This should be fine, but there's a (small) chance that someone there was relying on the order of arguments, and passing a value as positional argument.

To illustrate:

def plot_something(sequence, foo=True, bar=False, baz=False):
    # ...

plot_something(seq, False, True)

If the bar=False parameter gets removed, the final line would silently keep working, but the argument values would be passed differently.

We should discuss whether (and in which cases!) we should use keyword-only arguments. E.g., a function like the following would not allow to pass values to foo and bar by position:

def plot_something(sequence, *, foo=True, bar=False, baz=False):
    # ...

plot_something(seq, False, True)  # Results in an error, as there is only 1 positional argument

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions