__contains__ hook: follow-up

Feb. 5, 2000
12:15 a.m.
I've sent a patch to patches@python.org which does the 'in' hook in the pseudo-right way: adding a slot to the sequence methods structure, and adding a flag to support it for backwards compatability. Now that it's there, I've also changed instance method to use it, and to map it to __contains__. The code there also has special-case for strings, so if someone (maybe me) adds such a slot to strings, then the code will only have to do the C equivalent of try: obj.__contains__(whatever) except AttributeError: for element in obj: if element == whatever: return 1 return 0 Is this desirable? It shouldn't be too hard... -- Moshe Zadka <mzadka@geocities.com>. INTERNET: Learn what you know. Share what you don't.
9173
Age (days ago)
9173
Last active (days ago)
0 comments
1 participants
participants (1)
-
Moshe Zadka