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()."


Core Modules

More Standard Modules

Threads and Processes

Data Representation

File Formats

Mail and News Message Processing

Network Protocols

Internationalization

Multimedia Modules

Data Storage

Tools and Utilities

Platform-Specific Modules

Implementation Support Modules

Other Modules



Python Standard Library
Python Standard Library (Nutshell Handbooks) with
ISBN: 0596000960
EAN: 2147483647
Year: 2000
Pages: 252
Authors: Fredrik Lundh

Flylib.com © 2008-2020.
If you may any questions please contact us: flylib@qtcs.net