New submission from Tsvika Shapira <tsvi...@gmail.com>:

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 <rep...@bugs.python.org>
<https://bugs.python.org/issue36627>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to