python alternative code