90% of the time
[:]
could be replaced bylist()
. Of course it won’t work for everything since the two are not strictly equivalent, but it is worth trying. Next time you see a[:]
try to replace it withlist
, your code should be more readable. Do it, the devil is in the details.
I would use b = [element for element in a]
instead. Using b = list(a)
is not explicit enough for me when a
is already a list -- it's quite confusing. My options is more explicit in that we're creating a list from the elements of a
, whatever a is.