New submission from Tsvika Shapira <[email protected]>:
the following code:
```
lists_to_filter = [
['a', 'exclude'],
['b']
]
# notice that when 'exclude' is the last element, the code returns the expected
result
for exclude_label in ['exclude', 'something']:
lists_to_filter = (labels_list for labels_list in lists_to_filter if
exclude_label not in labels_list)
# notice that changing the line above to the commented line below (i.e.
expanding the generator to a list) will make the code output the expected
result,
# i.e. the issue is only when using filter on another filter, and not on a
list
# lists_to_filter = [labels_list for labels_list in lists_to_filter if
exclude_label not in labels_list]
lists_to_filter = list(lists_to_filter)
print(lists_to_filter)
```
as far as i understand, the code above should output "[['b']]"
instead it outputs "[['a', 'exclude'], ['b']]"
----------
messages: 340200
nosy: Tsvika Shapira
priority: normal
severity: normal
status: open
title: composing filter() doesn't work as expected
type: behavior
versions: Python 3.6, Python 3.7
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue36627>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com