default value parameter

Lima·2021년 2월 23일
0

python

목록 보기
2/6
post-thumbnail
def fun1(a="who is you", b="True", x, y):
	print a,b,x,y
func1("ok a", "ok b", 1)  # Is 1 assigned to x or ?
func1(1)                  # Is 1 assigned to a or ?
func1(1, 2)               # ?
def example(a, b, c=None, r="w" , d=[], *ae,  **ab):

(a,b) are positional parameter
(c=none) is optional parameter
(r="w") is keyword parameter
(d=[]) is list parameter
(*ae) is keyword-only
(**ab) is var-keyword parameter

def fun1(a="who is you", b="True", *, x, y):

In Python 3 however, you may do the following:
which makes x and y keyword only so you can do this:

fun1(x=2, y=2)

0개의 댓글