-
-
Notifications
You must be signed in to change notification settings - Fork 414
Description
Sorry for creating a blank ticket, but this is not a bug nor a new rule.
At the current version wemake_python_styleguide: 0.16.1 the documentation states, for rule WPS435, ListMultiplyViolation , the following:
When you multiply lists - it does not create new values, it creates references to the existing value. It is not what people mean in 99.9% of cases.
And that this block is wrong:
# Wrong:
my_list = [1, 2, 3] * 3
This explanation is incorrect. The example does create new values:
row = [1, 2, 3]
mylist = row * 3
row[0] = 'X'
print(mylist)
This prints [1, 2, 3, 1, 2, 3, 1, 2, 3].
Moreover, the link with the explanation seems off.
Instead of
https://github.com/satwikkansal/wtfPython#-explanation-8
it seems like it should be:
https://github.com/satwikkansal/wtfPython#-a-tic-tac-toe-where-x-wins-in-the-first-attempt
I would suggest replacing the link and copying the example found there:
# Let's initialize a row
row = [""] * 3 #row i['', '', '']
# Let's make a board
board = [row] * 3
>>> board
[['', '', ''], ['', '', ''], ['', '', '']]
>>> board[0]
['', '', '']
>>> board[0][0]
''
>>> board[0][0] = "X"
>>> board
[['X', '', ''], ['X', '', ''], ['X', '', '']]
This would be a simple update in the documentation, maybe I could fix it?