The functions defined in the string module, which are currently str methods, are deprecated in Python 2.4 and should not be used at all, although they were stored in later versions of Python 2 for backward compatibility. They were removed in Python 3.0.
- Why does the second code work without importing the string module?
Because it is a method like str .
- Is there a performance improvement when using one over the other?
Well, string.find(x, y) calls x.find(y) , but performance doesn't matter here (see first sentence).
source share