In Perl in can put a scalar variable in a regex as the pattern. for example: m/$var/ where $var contains the string I want to match Is there a way to do this in Python?