Inline Variable¶
Sourcery refactoring id: inline-variable
¶
Description:¶
Inline variable that is only used once
Before:¶
thelist = []
for i in range(10):
k = i**2
thelist.append(k)
After:¶
thelist = []
for i in range(10):
thelist.append(i**2)
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.