The following line returns an error:
self.m, self.userCodeToUserNameList, self.itemsList, self.userToKeyHash, self.fileToKeyHash = readUserFileMatrixFromFile
It's common to use _
to denote unneeded variables.
a, b, c, d, e, _ = my_func_that_gives_6_values()
This is also often used when iterating a certain number of times.
[random.random() for _ in range(10)] # gives 10 random values
Python 3 also introduced the *
for assignment, similar to how *args
takes an arbitrary number of parameters. To ignore an arbitrary number of arguments, just assign them to *_
:
a, b, c, d, e, *_ = my_func_that_gives_5_or_more_values()
This can be used at any point in your assignment; you can fetch the first and last values and ignore padding in the middle:
>>> a, b, c, *_, x, y, z = range(10)
>>> print(a, b, c, '...', x, y, z)
0 1 2 ... 7 8 9