from six import PY2 if PY2: def ascii(obj): ... def func(p): X = ascii(42) + 'foo'