Python best practice and some pitfalls