[issue42475] wrongly cache pattern by re.compile

2020-11-26 Thread Matthew Barnett
Matthew Barnett added the comment: That behaviour has nothing to do with re. This line: samples = filter(lambda sample: not pttn.match(sample), data) creates a generator that, when evaluated, will use the value of 'pttn' _at that time_. However, you then bind 'pttn' to something else.

[issue42475] wrongly cache pattern by re.compile

2020-11-26 Thread ProFatXuanAll
New submission from ProFatXuanAll : When I run the following code, I expected to get output result `['i am next line with [unk]']`, but instead I get the original list in `data`. Code snippet ```py import re data = [ '= hello =', 'i am next line with ', ] pttn = re.compile(r'=.*=')