'aspambspamcspamto access the same operation through the string module in python xyou need to import the module (at least once in your processand pass in the objectimport string string replace( '+''spam' 'aspambspamcspambecause the module approach was the standard for so longand because strings are such central component of most programsyou might see both call patterns in python code you come across againthoughtoday you should always use method calls instead of the older module calls there are good reasons for thisbesides the fact that the module calls have gone away in for one thingthe module call scheme requires you to import the string module (methods do not require importsfor anotherthe module makes calls few characters longer to type (when you load the module with importthat isnot using fromandfinallythe module runs more slowly than methods (the module maps most calls back to the methods and so incurs an extra call along the waythe original string module itselfwithout its string method equivalentsis retained in python because it contains additional toolsincluding predefined string constants ( string digitsand template object system-- relatively obscure formatting tool that predates the string format method and is largely omitted here (for detailssee the brief note comparing it to other formatting tools aheadas well as python' library manualunless you really want to have to change your code to use xthoughyou should consider any basic string operation calls in it to be just ghosts of python past string formatting expressions although you can get lot done with the string methods and sequence operations we've already metpython also provides more advanced way to combine string processing tasks--string formatting allows us to perform multiple type-specific substitutions on string in single step it' never strictly requiredbut it can be convenientespecially when formatting text to be displayed to program' users due to the wealth of new ideas in the python worldstring formatting is available in two flavors in python today (not counting the less-used string module template system mentioned in the prior section)string formatting expressions% (valuesthe original technique available since python' inceptionthis form is based upon the language' "printfmodeland sees widespread use in much existing code string fundamentals