improving for python best-practice