Your code is essentially equivalent
TotSize[:] = map(sum, data)
This will summarize all data , not just the first rows of row and firs col cols. It will also resize TotSize to fit the number of rows of data (assuming TotSize is a list).
I wonder why you go to the list that should store the result. In Python, you usually just return this list:
def row_sums(data): return map(sum, data)
Now it is doubtful whether it is worth defining a function for this at all ...
source share