menu = {
        'soup': 'lentil',
        'oyster': 'tongyoung',
        'special': 'schnitzel',
    }
    template = ('Today\'s soup is %(soup)s, '
                'buy one get two %(oyster)s oysters, '
                'and our special entrée is %(special)s.')
    formatted = template % menu
    print(formatted)
    
    >>>
    
    Today's soup is lentil, buy one get two tongyoung oysters, and our special entrée is schnitzel.

    이 형식화 식이 어떤 결과를 만드는지 이해하려면 코드를 위아래로 계속 훑어보면서 형식화 문자열과 딕셔너리를 뒤져야 한다. 이런 식의 불연속성 때문에 버그를 찾기 힘들고, 형식화에 사용할 값 중 일부를 약간 변경해야 할 경우 가독성이 더 나빠진다.

    따라서 더 나은 방법이 있어야만 한다.

    신간 소식 구독하기
    뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.