Partial evaluation in Python