Message from Python discussions

December 2018

— new_list = filter(None, my_lists)

— 

Language:

py3


Source:
my_list = [
['list'],
[],
['list too']
]
print(filter(None,my_list))


Result:
<filter object at 0x7f4ffdba94a8>

— That's right

— Wrap it in list

— list(filter(None, my_list)) if you want to have a list from filter

— `print(list(filter(None, my_list)))`

— Language:

py3


Source:
ok = []
my_list = [
['list'],
[],
['list too']
]
for i in my_list:
ok.append(list(filter(None, i)))
print(ok)

# how if in append ?


Result:
[['list'], [], ['list too']]

Message permanent page

— .... why?

— Language:

python3


Source:
my_list = [
['list'],
[],
['list too']
]
print(list(filter(None,my_list)))


Result:
[['list'], ['list too']]

Message permanent page

— Language:

py3


Source:
ok = []
my_list = [
['list'],
[],
['list too']
]
for i in list(filter(None, my_list)):
ok.append({'o': i})
print(ok)


Result:
[{'o': ['list']}, {'o': ['list too']}]

Message permanent page

— Or this?

— How to print binary of 1024