I assume this is just checking string equality, in which case I think '==' would be a better choice. Using "is" works because of the way cPython handles strings, but is is a language guarantee that equal strings will always be the same object? Or is than an implementation coincidence?

In either case, if the question being asked is "are these values equal", I think it's more clear to use the equality operator. Same applies to some other lines below.