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:
-
shlex.split(s[, comments[, posix]])¶ 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 thecommentersmember of theshlexinstance to the empty string). This function operates in POSIX mode by default, but uses non-POSIX mode if the posix argument is false.New in version 2.3:
New in version 2.3.