@1 decorator - 데커레이터 decorator 패턴은 '@'표기를 사용해 함수 또는 메서드의 변환을 우아하게 지정해준다'함수의 객체'와 '함수를 변경하는 다른 객체'의 wrapping을 허용한다@decodef method(arg): # method... passdecorator 를 사용한 위 코드는 아래코드와 같다def method(arg): # method... passmethod = deco(method)import functoolsimport timeline_len = 80def clen(s): """Calculate the effective length of a string considering full-width characters.""" return sum(1 if ord(c) >= 0x2E80 else.. 2024. 10. 30. 이전 1 다음