The strop Module

(Obsolete) The strop is a low-level module that provides fast C implementations of most functions in the string module. It is automatically included by string, so theres seldom any need to access it directly.

However, one reason to use this module is if you need to tweak the path before you start loading Python modules. Example 13-5 demonstrates the module.

Example 13-5. Using the strop Module

File: strop-example-1.py import strop import sys # assuming we have an executable named ".../executable", add a # directory named ".../executable-extra" to the path if strop.lower(sys.executable)[-4:] == ".exe": extra = sys.executable[:-4] # windows else: extra = sys.executable sys.path.insert(0, extra + "-extra") import mymodule

In Python 2.0 and later, you should use string methods instead of strop. In Example 13-5, replace "strop.lower(sys.executable)" with "sys.executable.lower()."

Категории