News for hackers. Stuff that matters.
Re:Pattern matching accepted for Python by joshuamorton on Tuesday February 09, 2021 @06:41PM (#26084055)
Fwiw, I find creating a 2d array and then flattening (`itertools.chain.from_iterable([[None for _y in range(y)] for _x in range(x)])` to be both readable and reasonably concise, though yes explicit loops are also fine.
Re:Pattern matching accepted for Python by cat199 on Tuesday February 09, 2021 @11:21PM (#26085724)
nice trick.. though if you are relying on the 'generator' aspect of comprehensions this may be problematic (will create in-memory copies)