Python improvement