This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mrabarnett
Recipients ProFatXuanAll, ezio.melotti, mrabarnett
Date 2020-11-26.19:45:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1606419936.48.0.426413017555.issue42475@roundup.psfhosted.org>
In-reply-to
Content
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.

Here's a simple example:

>>> x = 1
>>> func = lambda: print(x)
>>> func()
1
>>> x = 2
>>> func()
2

A workaround is to capture the current value with a default argument:

>>> x = 1
>>> func = lambda x=x: print(x)
>>> func()
1
>>> x = 2
>>> func()
1
History
Date User Action Args
2020-11-26 19:45:36mrabarnettsetrecipients: + mrabarnett, ezio.melotti, ProFatXuanAll
2020-11-26 19:45:36mrabarnettsetmessageid: <1606419936.48.0.426413017555.issue42475@roundup.psfhosted.org>
2020-11-26 19:45:36mrabarnettlinkissue42475 messages
2020-11-26 19:45:36mrabarnettcreate