mode code more pythonic