Regular expression issue

MRAB python at
Mon Aug 9 16:14:16 CEST 2010

genxtech wrote:
> On Aug 8, 7:34 pm, Tim Chase <python.l... at> wrote:
>> On 08/08/10 17:20, genxtech wrote:
>>> if, in_string) != None:
>> While the other responses have addressed some of the big issues,
>> it's also good to use
>>    if thing_to_test is None:
>> or
>>    if thing_to_test is not None:
>> instead of "== None" or "!= None".
>> -tkc
> I would like to thank all of you for your responses.  I understand
> what the regular expression means, and am aware of the double negative
> nature of the test.  I guess what I am really getting at is why the
> last test returns a value of None, and even when using the syntax
> suggested in this quoted solution, the code for the last test is doing
> the opposite of the previous 2 tests that also returned a value of
> None.  I hope this makes sense and clarifies what I am trying to ask.
It returns None because it doesn't match.

Why doesn't it match?

Because the regex wants the last character to be a 'y', but it isn't,
it's a 'a'.

More information about the Python-list mailing list