A simplified version of my problem:
I have an understanding of the list, which I use to set bit flags in a two-dimensional list, so:
s = FLAG1 | FLAG2 | FLAG3
[[c.set_state(s) for c in row] for row in self.__map]
All set_state value:
self.state |= f
This works fine, but I have to have this set_state function in every cell in __map. Each cell in __map has a .state, so I'm trying to do something like:
[[c.state |= s for c in row] for row in self.map]
or
map(lambda c: c.state |= s, [c for c in row for row in self.__map])
Except that it does not work (syntax error). I may bark the wrong tree with map / lamda, but I would like to get rid of set_state. And perhaps you know why the assignment does not work in list comprehension
source
share