[Tutor] string.search

john public apython101@yahoo.com
Wed, 5 Dec 2001 05:51:43 -0800 (PST)


--0-1935904150-1007560303=:87024
Content-Type: text/plain; charset=us-ascii


 I think string.search() is what I am looking for but without an actual example I can't figure it out. I started programming three weeks ago. I have lived with many programmers in the past and I am realizing I learned some BASIC by osmosis. Once I find the right tool for the job, is there some online documentation that has a real example for everything. I checked Guido's tutorial and the Python reference library but could only find examples in the abstract. 
such as string.search(string,[,pos[,endpos]]) 
in the case below I interpreted this to be
t1.search(t1[,0[,3]]) however I noticed that Python is not being informed as to what piece of the list it is searching. I tried running it a few times anyway but got error messages. Unfortunately the until I can become morfe familiar with the format of Python the Python Reference manual will be of little help since it does not give real examples.
  alan.gauld@bt.com wrote: 
> this short piece of code works using the membership
> function. However adding what is below:
> 
> t1 = "a little red moon"
> t2 = t1
> t3 = "redmond washington"
> 
> if ("r" in t2):
> print "t2"
> print t2
> 
> if ("re" in t2):

The membership operator only works for single items.
You need the string functions for this: string.search()
in this case.

Alan G

 



---------------------------------
Do You Yahoo!?
Buy the perfect holiday gifts at Yahoo! Shopping.
--0-1935904150-1007560303=:87024
Content-Type: text/html; charset=us-ascii

<P> I think string.search() is what I am looking for but without an actual example I can't figure it out. I started programming three weeks ago. I have lived with many programmers in the past and I am realizing I learned some BASIC by osmosis. Once I find the right tool for the job, is there some online documentation that has a real example for everything. I checked Guido's tutorial and the Python reference library but could only find examples in the abstract. 
<P>such as string.search(string,[,pos[,endpos]]) 
<P>in the case below I interpreted this to be
<P>t1.search(t1[,0[,3]]) however I noticed that&nbsp;Python is not being informed as to what piece of the list it is searching. I tried running it a few times anyway but got error messages. Unfortunately&nbsp;the&nbsp;until I can become morfe familiar with the format of Python the Python Reference manual will be of little help since it does not give real examples.
<P>&nbsp; <B><I>alan.gauld@bt.com</I></B> wrote: 
<BLOCKQUOTE style="BORDER-LEFT: #1010ff 2px solid; MARGIN-LEFT: 5px; PADDING-LEFT: 5px">
<P>&gt; this short piece of code works using the membership<BR>&gt; function. However adding what is below:<BR>&gt; <BR>&gt; t1 = "a little red moon"<BR>&gt; t2 = t1<BR>&gt; t3 = "redmond washington"<BR>&gt; <BR>&gt; if ("r" in t2):<BR>&gt; print "t2"<BR>&gt; print t2<BR>&gt; <BR>&gt; if ("re" in t2):<BR><BR>The membership operator only works for single items.<BR>You need the string functions for this: string.search()<BR>in this case.<BR><BR>Alan G</P>
<P>&nbsp;</P></BLOCKQUOTE><p><br><hr size=1><b>Do You Yahoo!?</b><br>
Buy the perfect holiday gifts at <a
href="http://rd.yahoo.com/O=1/I=brandr-mailfooter/*http://shopping.yahoo.com">Yahoo! Shopping</a>.
--0-1935904150-1007560303=:87024--