On 13/05/2006 1:55 AM, vbgunz wrote:
> I forgot to explain my reason for over shadowing the 'string' built-in
> within my iterator. To me, it doesn't matter because the string
> identifier is temporary within the function and dies when the function
> dies. Also, I personally don't use the string fu
On 13/05/2006 1:45 AM, vbgunz wrote:
> Hello John,
>
> Thank you very much for your pointers! I decided to redo it and try to
> implement your suggestion. I think I did a fair job and because of your
> suggestion have a better iterator. Thank you!
>
> def indexer(string, substring, overlap=1):
>
I forgot to explain my reason for over shadowing the 'string' built-in
within my iterator. To me, it doesn't matter because the string
identifier is temporary within the function and dies when the function
dies. Also, I personally don't use the string function and prefer
''.join('hi'), etc. Also, a
Hello John,
Thank you very much for your pointers! I decided to redo it and try to
implement your suggestion. I think I did a fair job and because of your
suggestion have a better iterator. Thank you!
def indexer(string, substring, overlap=1):
'''indexer(string, substring, [overlap=1]) -> int
On 12/05/2006 5:13 AM, vbgunz wrote:
> I thought this to be a great exercise so I went the extra length to
> turn it into a function for my little but growing library. I hope you
> enjoy :)
>
Oh, indeed ;-)
>
> def indexer(string, target):
Consider not shadowing the name of the string module.
Scott David Daniels wrote:
> [EMAIL PROTECTED] wrote:
> print list(positions('1234', 'abcd efgd 1234 fsdf gfds abcde 1234'))
>
> prints:
> [10, 31]
>
Nicer than mine ;)
Shows I need to get a job where I use python more!
--
http://mail.python.org/mailman/listinfo/python-list
I thought this to be a great exercise so I went the extra length to
turn it into a function for my little but growing library. I hope you
enjoy :)
def indexer(string, target):
'''indexer(string, target) -> [list of target indexes]
enter in a string and a target and indexer will either re
Paul Rubin wrote:
>[EMAIL PROTECTED] writes:
>
>
>>say i have string like this
>>astring = 'abcd efgd 1234 fsdf gfds abcde 1234'
>>if i want to find which postion is 1234, how can i achieve this...? i
>>want to use index() but it only give me the first occurence. I want to
>>know the positions o
[EMAIL PROTECTED] wrote:
>hi
>say i have string like this
>astring = 'abcd efgd 1234 fsdf gfds abcde 1234'
>if i want to find which postion is 1234, how can i achieve this...? i
>want to use index() but it only give me the first occurence. I want to
>know the positions of both "1234"
>thanks
>
>
[EMAIL PROTECTED] writes:
> say i have string like this
> astring = 'abcd efgd 1234 fsdf gfds abcde 1234'
> if i want to find which postion is 1234, how can i achieve this...? i
> want to use index() but it only give me the first occurence. I want to
> know the positions of both "1234"
Most straig
[EMAIL PROTECTED] wrote:
> astring = 'abcd efgd 1234 fsdf gfds abcde 1234'
> i want to find all positions of '1234' in astring.
def positions(target, source):
'''Produce all positions of target in source'''
pos = -1
try:
while True:
po
alisonken1 wrote:
> ==
> def getAllIndex(aString=None, aSub=None):
> t=dict()
> c=0
> ndx=0
> while True:
> try:
> ndx=aString.index(aSub, ndx)
> t[c]=ndx
> ndx += 1
> c += 1
> except ValueError:
>
[EMAIL PROTECTED] wrote:
> hi
> say i have string like this
> astring = 'abcd efgd 1234 fsdf gfds abcde 1234'
> if i want to find which postion is 1234, how can i achieve this...? i
> want to use index() but it only give me the first occurence. I want to
> know the positions of both "1234"
> thank
> say i have string like this
> astring = 'abcd efgd 1234 fsdf gfds abcde 1234'
> if i want to find which postion is 1234, how can i
> achieve this...? i want to use index() but it only give
> me the first occurence. I want to know the positions of
> both "1234"
Well, I'm not sure how efficient it
14 matches
Mail list logo