5

I want to write something like this.

  1. def func_name(arg1, arg2, arg3 = 3) #this defines default value for optional argument arg3

  2. def func_name(arg1, arg2, arg3: int) #and this defines data type for required argument arg3

Is there any possible method to define both of them? Something like this

def func_name(arg1, arg2, arg3 = 3: int)

1

1 Answer 1

23

You can use like this.

def boo(arg1, arg2, arg3: int = 10):
    ....

You can find more information PEP 484's section on default argument values

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.