Inline Variable
Documentation Index
Fetch the complete documentation index at: https://docs.sourcery.ai/llms.txt
Use this file to discover all available pages before exploring further.
Sourcery refactoring id: inline-variable
Section titled “Sourcery refactoring id: inline-variable”Description:
Section titled “Description:”Inline variable that is only used once
Before:
Section titled “Before:”thelist = []for i in range(10): k = i**2 thelist.append(k)After:
Section titled “After:”thelist = []for i in range(10): thelist.append(i**2)Explanation:
Section titled “Explanation:”Inlining variable can help to streamline the code, but can also make it less readable. Sourcery will only inline variables where doing so allows further readability changes to be made, such as converting a loop into a list comprehension.