This whole algorithm could just be `return expr.subs([(var, Symbol('variable_%d' % i)) for i, var in enumerate(self.nargs)])`.