Skip to content

Optional arguments #110

Open
Open
@GatorQue

Description

@GatorQue

When a function/method has arguments with a default value assigned all other callers of the function/method should explicitly specify the optional argument name.

def foo(bar=None, zoo=None):
pass

Bad:
foo(1, "lion")

Good:
foo(bar=1, zoo="lion")

Rationale:
Additional optional arguments will likely be added to the function/method in the future and the callers won't need to be hunted down and updated to account for the new optional argument added.

Example:
def foo(flag=True, bar=None, zoo=None):
pass

Bad:
foo(1, "lion") # unexpected result since flag is now assigned 1 and bar is now assigned "lion"

Good:
foo(bar=1, zoo="lion") # No change necessary - behaves the same as before

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions