On Thu, Jun 27, 2019 at 9:13 AM Steven D'Aprano <st...@pearwood.info> wrote:
> The only risk here is if your refactoring does something silly, such as > reusing a variable which overrides assignment: > How would you propose to write this code without reusing a variable? def frobnicate(data): stuff = [] for datum in data: f = process_the(data) g = munge_result(f) stuff.append(g) return stuff Under the proposal, we have no guarantee that each iteration through the loop will give us a new `f` to work with. Maybe yes, maybe no. Without looking at the source code in `process_the()` we have no way of knowing whether `f` is being bound to a new object each time or some completely different arbitrary action. -- Keeping medicines from the bloodstreams of the sick; food from the bellies of the hungry; books from the hands of the uneducated; technology from the underdeveloped; and putting advocates of freedom in prisons. Intellectual property is to the 21st century what the slave trade was to the 16th.
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/5IQOHCTV5F4KYHTWSYHYCF6PERZKOJ3S/ Code of Conduct: http://python.org/psf/codeofconduct/