The 6 AI Engineering Patterns, come build with Greg live:Β Starts Jan 6th, 2025
Leverage
Glossary

Argument

Python arguments and their usage

Python Argument refers to information that you pass into a function. A function can have 0, set amount, or infinite arguments passed to it. We’ll run through an example of each below.

Note: You may hear the word parameter get used. This is the same as argument and two can be used interchangeably.

def my_function(argument1, argument2):
# Do something

Another interesting aspect of function arguments is that they can have a default value. This means if you do not specify them when you call a function, then their default value will be used.

In fact, I bet you use more python argument defaults than you do specified arguments.


def my_function(arg1, arg2="default value"):
print (arg1, arg2)

my_function(arg1="Bob")

Returned: "Bob", "default value"
def my_function(argument1, argument2):
# Do something

You can name arguments whatever you want! Just be careful that you aren’t using a word that is already in the python namespace. You may get unintended results. Some of these are print, abs, for, while, etc.

Arguments are extremely common throughout the Python language and its libraries. In fact, it’s extremely popular as a part of fundamental coding languages in general.

Let’s take a look at a python argument code sample.

Link to code

On this page

No Headings