Be consistent with the order of your parameters


Python Clean Code Tip:

Be consistent with order of parameters for similar functions/methods. Don't confuse your readers.

# bad
def give_first_dose_of_vaccine(person, vaccine):
    print(f"Give first dose of {vaccine} to {person}.")


def give_second_dose_of_vaccine(vaccine, person):
    print(f"Give second dose of {vaccine} to {person}.")


give_first_dose_of_vaccine("john", "pfizer")
# Give first dose of pfizer to john.
give_second_dose_of_vaccine("jane", "pfizer")
# Give second dose of jane to pfizer.


# good
def give_first_dose_of_vaccine(person, vaccine):
    print(f"Give first dose of {vaccine} to {person}.")


def give_second_dose_of_vaccine(person, vaccine):
    print(f"Give second dose of {vaccine} to {person}.")


give_first_dose_of_vaccine("john", "pfizer")
# Give first dose of pfizer to john.
give_second_dose_of_vaccine("jane", "pfizer")
# Give second dose of pfizer to jane.