fix bug of template expand for python mode