[Steven D'Aprano] >> 4. I normally dislike global flags, but this is one time it might be >> less-worse than the alternatives. >> >> Modify SequenceMatcher to test for the value of a global flag, >> defaulting to False if it doesn't exist. >> ... >> The flag will only exist if the caller explicitly creates it: >> >> import difflib >> difflib.disable_heuristic = True >> ...
A module global is a non-starter for me (for all the usual reasons about the potentially horrid sociopathic consequences of one piece of an app changing behavior for the entire app - fine if it's a small app wholly understood by the user, potential nightmares if it's a large app nobody understands <0.3 wink>). [Nick Coghlan] > Why make it a global? A property on the SequenceMatcher object should > be able to do the right thing. > ... The pragmatic drawback is that the heuristics we're trying to disable typically execute _during_ SequenceMatcher instance construction. That's why it makes most sense to convey the information to the constructor. Setting a property after the instance is created is typically too late (unless several other SequenceMatcher methods are rewritten to delay analyzing the second sequence). > A flag on the object rather than a per-call flag may actually be the > better API here anyway. The call in question here is the constructor (__init__), so there's no real difference between "on the object" and "per call" in this case. _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com