Re: str.count algorithm

2010-05-04 Thread Peter Otten
Raymond Hettinger wrote: > On May 4, 12:12 pm, Hellnar wrote: >> Hello, >> I am trying to find what algorithm Python uses for the built-in >> str.count function, if it has a name. > > Roughly the same as: > >sum(1 for c in s if c == tgt) That would be list.count(), I think. OP, the source

Re: str.count algorithm

2010-05-04 Thread Raymond Hettinger
On May 4, 12:12 pm, Hellnar wrote: > Hello, > I am trying to find what algorithm Python uses for the built-in > str.count function, if it has a name. Roughly the same as: sum(1 for c in s if c == tgt) Raymond -- http://mail.python.org/mailman/listinfo/python-list

str.count algorithm

2010-05-04 Thread Hellnar
Hello, I am trying to find what algorithm Python uses for the built-in str.count function, if it has a name. Thanks -- http://mail.python.org/mailman/listinfo/python-list