Asterisk
Asterisk : unpacking a container tuple, dict 등 자료형에 들어가 있는 값을 unpacking 함수의 입력값, zip 등에 유용하게 사용가능 -. tuple을 넘김 123456def asterisk_test(a, *args): print(a, args) print(type(args)) asterisk_test(1, 2, 3, 4, 5, 6) Colored by Color Scriptercs Output : 1 (2, 3, 4, 5, 6) -. dict를 넘길 때는 **를 두번씀12345def asterisk_test(a, **kargs): print(a, kargs) print(type(kargs)) asterisk_test(1, b = 2, c = 3, d = 4, e..
2019. 5. 6.
Lambda & MapReduce
(1) Lambda : 함수 이름 없이, 함수처럼 쓸 수 있는 익명함수 -. 일반적인 함수123def f(x,y): return x + yprint(f(1, 4))cs Output : 5 -. 람다 함수 1234f = lambda x, y: x + y print(f(1, 4)) cs Output : 5 (2) Map Function : Sequence 자료형 각 element에 동일한 function을 적용함 -> map(function_name, list_data) 123456ex = [1, 2, 3, 4, 5]g = lambda x: x*2f = lambda x,y: x + y print(list(map(g, ex)))print(list(map(f, ex, ex)))cs Output : [2, 4, ..
2019. 5. 6.