본문 바로가기

English Articles

how to make a shorter named function which is originally a long-named function

It is simple.

define another function with shorter name, and just run the original function and return the result.

 

the following is an example of it.

original function is named too long. make short-named function and call original function and return the result of it.

it does not take that much time more. 

 

def a_function_which_is_too_long_to_use(in1, in2):
	res_orignial = in1 + in2
    return(res_orignial)
    
def short_named(in3, in4):
	res_new = a_function_which_is_too_long_to_use(in3, in4)
    return(res_new)

 

but this is a waste of resources and code.

the best thing is, change original function name to a shorter one.


함수 이름 너무길때, 그밑에 짧은이름 으로 함수를 하나 더 정의해서, 기존함수 실행하고 리턴 역시 기존함수 리턴값으로 준다.

이 방법은 임시땜빵으로만 쓰고, 원래함수 이름을 좀 더 줄이는게 좋다.