Keyword Argument

noun

say it: “KEE-wurd AR-gyuh-ment” /ˈkiˌwɝd ˈɑːrɡjəmənt/

An argument passed by naming its parameter, such as size="large", so the order doesn't matter and the call is easier to read.

What is a keyword argument?

A keyword argument is passed by naming the parameter, so the order doesn't matter and the call is easier to read.

def book_flight(origin, destination):
    print(f"{origin} to {destination}")

book_flight(destination="Chicago", origin="Denver")  # Denver to Chicago

In a sentence

  • “destination="Chicago" is a keyword argument.”
  • “With keyword arguments, book_flight(destination="Chicago", origin="Denver") still works.”

Level: Apprentice · More Python terms at this level

Updated