views:

71

answers:

2

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)?
+2  A: 

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

krs1
+6  A: 

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.

S.Lott
Because I program in Python about twice a year :-) But apologies to all, I _am_ using the class, I just found the wrong doco. Stupid! Stupid! Stupid!
paxdiablo