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:
Nonefor s will read the string to split from standard input.
The shlex module defines the following class:
|[instream[, infile[, posix]]])|
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 22.2.1.