V
V
vhsporno2020-01-04 13:33:35
PHP
vhsporno, 2020-01-04 13:33:35

How to unpack list of lists nth number of times?

The bottom line is that in the database there are fields with the value ArrayField(models.IntegerField). I am filtering the data. I take and pull this data through values_list.
I get data like:

[([123],), (None,), (None,), (None,), (None,), (None,), ([65, 66],), ([123],), [123]]

Need to get a list of numbers: How to implement it?
[123, 65, 66, 123, 123]

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Dart, 2019-03-10
@gobananas

I venture to guess:

if((mysql_num_rows($query[0]) > 0 AND $postk['status']=='active')
|| 
($postk['win_row_col']>=$postk['win_row'] && $postk['race_col']>=$postk['race'] && $postk['loose']>=$postk['loose_row'])){

V
vhsporno, 2020-01-04
@vhsporno

It was enough to do .values_list(flat=True)
Then get a list of lists.
And unpack it like this:
flat_list = [item for sublist in lst if sublist for item in sublist ]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question