Re: [Python-Dev] Re: Generalizing "in" to pairs of sequences
Sometimes I find myself wishing that strings had a method "substringp" that would do basically what Eric wants, like
'cabcd'.substringp('ca') 1 'cabcd'.substringp('xx') 0
substringp would probably be the wrong name for it, though. Alex.
"AC" == Alex Coventry
writes:
AC> Sometimes I find myself wishing that strings had a method AC> "substringp" that would do basically what Eric wants, like >> 'cabcd'.substringp('ca') AC> 1 >> 'cabcd'.substringp('xx') AC> 0 AC> substringp would probably be the wrong name for it, though. Hmm, "hassubstring()"? not-implying-a-vote-on-adding-such-a-method-ly y'rs, -Barry
Barry A. Warsaw
AC> substringp would probably be the wrong name for it, though.
Hmm, "hassubstring()"?
How about "contains"? E.g. if a.contains(b): # do stuff -- <a href="http://www.tuxedo.org/~esr/">Eric S. Raymond</a> (Those) who are trying to read the Second Amendment out of the Constitution by claiming it's not an individual right (are) courting disaster by encouraging others to use the same means to eliminate portions of the Constitution they don't like. -- Alan Dershowitz, Harvard Law School
"ESR" == Eric S Raymond
writes:
>> substringp would probably be the wrong name for it, though. >> Hmm, "hassubstring()"? ESR> How about "contains"? E.g. | if a.contains(b): | # do stuff Heh, and from there it's a small leap to a.__contains__(b), a.k.a. "b in a". Sneaky Eric, very sneaky. :) -Barry
Barry A. Warsaw
ESR> How about "contains"? E.g.
| if a.contains(b): | # do stuff
Heh, and from there it's a small leap to a.__contains__(b), a.k.a. "b in a".
Sneaky Eric, very sneaky. :)
You know, that didn't consciously occur to me. Which only goes to show that my unconscious mind is even *more* evil...BWAHAHAHAHAA! -- <a href="http://www.tuxedo.org/~esr/">Eric S. Raymond</a> Society in every state is a blessing, but government even in its best state is but a necessary evil; in its worst state an intolerable one; for when we suffer, or are exposed to the same miseries *by a government*, which we might expect in a country *without government*, our calamities is heightened by reflecting that we furnish the means by which we suffer." -- Thomas Paine
participants (3)
-
Alex Coventry
-
barry@zope.com
-
Eric S. Raymond