Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What to use for Python string.find?

The documentation for Python 2.7 lists string.find as a deprecated function but does not (unlike atoi and atol) provide an alternative.

I'm coding in 2.7 at the moment so I'm happy to use it but I would like to know:

  • what is it going to be replaced with?
  • is that usable in 2.7 (if so, I'll use it now so as to avoid recoding later)?
like image 242
paxdiablo Avatar asked Sep 15 '10 02:09

paxdiablo


2 Answers

Almost the entire string module has been moved to the str type as method functions.

Why are you using the string module, when almost everything you need is already part of the string type?

http://docs.python.org/library/stdtypes.html#str.find

The string type -- and it's methods -- is not deprecated. Indeed, it will me morphed to include Unicode in Python 3.

like image 147
S.Lott Avatar answered Oct 23 '22 20:10

S.Lott


A lot of methods in string have been replaced by the str class. Here is str.find.

like image 6
krs1 Avatar answered Oct 23 '22 20:10

krs1