I was wondering whether there is a faster/better/cleaner way of element wise operations of arbitrarily nested list. I wrote something like this for 1 level nested lists and am wondering whether there are any good idioms in python. I did this after a ridiculous amount of bad thinking/missteps in python for the simplest of cases.
def init_p (arr): # input is always 2D matrix; init to uniform probability dist. q = [] row = len(arr) col = len(arr[0]) uni_dist = 1.0/(row *col) q = [ [uni_dist] * col for i in range(row)] return q Of course, without using external packages like numpy or any other scientific packages. sivaram -- _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor