**kwargs?

이동규 (Justin)·2020년 7월 18일
0

도대체 이게 뭔 외계어인가? 하며 검색해 보았다.

**kwargs는 Arbitrary Keyword Arguments의 줄임말이다.

w3schools.com의 설명을 그대로 옮긴다.

If you do not know how many keyword arguments that will be passed into your function, add two asterisk: before the parameter name in the function definition. This way, the function will receive a dictionary of arguments**, and can access the items accordingly.

말인즉슨, 함수를 만들 때 몇개의 매개변수가 필요한지 감이 안잡힌다면 인자 앞에 **를 붙여서 생성하라는 말이다. 예를 들어

def my_function(**params):
	for k,v in params.items():
    	print(i)

머 이런식으루.

profile
Frontend Developer, JamStack, Ethereum

0개의 댓글