Frame Hack Recipe: Ruby-Style String Interpolation¶
Step 1¶
Implement the interpolate
function, using a frame hack.
import sys
from string import Template
def interpolate(templateStr):
"""Implement this function"""
name = 'Feihong'
place = 'Chicago'
print interpolate("My name is ${name}. I work in ${place}.")
Expected output:
My name is Feihong. I work in Chicago.
Solution: solutions/interpolate1.py