Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python positional argument follows keyword argument

# When applying the arguments, Python first fills in the positional arguments, 
# then the keyword arguments.

# for example I have a function which has two arguments
def func(a, b):
    print("a=", a)
    print("b=", b)

#I will get an error if I call the function like this
func(a=5, 9) # 9 is the positional argument here. a is keyword argument

# correct way to call this function
func(5, 9) or func(5, b=9) or func(a=5, b=9)
 
PREVIOUS NEXT
Tagged: #python #positional #argument #keyword #argument
ADD COMMENT
Topic
Name
7+3 =