ASPN ActiveState Programmer Network
  ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups | Web Services
SEARCH
advanced | search help

Reference
ActivePython 2.4
Python Documentation
Library Reference
5. Miscellaneous Services
5.1 pydoc -- Documentation generator and online help system
5.2 doctest -- Test interactive Python examples
5.3 unittest -- Unit testing framework
5.4 test -- Regression tests package for Python
5.5 test.test support -- Utility functions for tests
5.6 decimal -- Decimal floating point arithmetic
5.7 math -- Mathematical functions
5.8 cmath -- Mathematical functions for complex numbers
5.9 random -- Generate pseudo-random numbers
5.10 whrandom -- Pseudo-random number generator
5.11 bisect -- Array bisection algorithm
5.12 collections -- High-performance container datatypes
5.13 heapq -- Heap queue algorithm
5.14 array -- Efficient arrays of numeric values
5.15 sets -- Unordered collections of unique elements
5.16 itertools -- Functions creating iterators for efficient looping
5.17 ConfigParser -- Configuration file parser
5.18 fileinput -- Iterate over lines from multiple input streams
5.19 calendar -- General calendar-related functions
5.20 cmd -- Support for line-oriented command interpreters
5.21 shlex -- Simple lexical analysis
5.21.1 shlex Objects
5.21.2 Parsing Rules

MyASPN >> Reference >> ActivePython 2.4 >> Python Documentation >> Library Reference >> 5. Miscellaneous Services
ActivePython 2.4 documentation

5.21 shlex -- Simple lexical analysis

New in version 1.5.2.

The shlex class makes it easy to write lexical analyzers for simple syntaxes resembling that of the Unix shell. This will often be useful for writing minilanguages, (for example, in run control files for Python applications) or for parsing quoted strings.

Note: The shlex module currently does not support Unicode input.

The shlex module defines the following functions:

split( s[, comments])
Split the string s using shell-like syntax. If comments is False (the default), the parsing of comments in the given string will be disabled (setting the commenters member of the shlex instance to the empty string). This function operates in POSIX mode. New in version 2.3.

The shlex module defines the following class:

class shlex( [instream[, infile[, posix]]])
A shlex instance or subclass instance is a lexical analyzer object. The initialization argument, if present, specifies where to read characters from. It must be a file-/stream-like object with read() and readline() methods, or a string (strings are accepted since Python 2.3). If no argument is given, input will be taken from sys.stdin. The second optional argument is a filename string, which sets the initial value of the infile member. If the instream argument is omitted or equal to sys.stdin, this second argument defaults to ``stdin''. The posix argument was introduced in Python 2.3, and defines the operational mode. When posix is not true (default), the shlex instance will operate in compatibility mode. When operating in POSIX mode, shlex will try to be as close as possible to the POSIX shell parsing rules. See section 5.21.1.

See Also:

Module ConfigParser:
Parser for configuration files similar to the Windows .ini files.



See About this document... for information on suggesting changes.

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState 2004 All rights reserved