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)

  • 4
    Does this answer your question? [Adding default parameter value with type hint in Python](https://stackoverflow.com/questions/38727520/adding-default-parameter-value-with-type-hint-in-python) – chash May 19 '20 at 14:17

1 Answers1

22

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

ojdo
  • 8,280
  • 5
  • 37
  • 60
Chih Sean Hsu
  • 423
  • 2
  • 10