Command-Line Modules

shlex

Lexes shell-like text into tokens and quotes individual arguments for POSIX shell syntax. split does not execute commands; quote is not a universal Windows-shell escaping mechanism. Prefer passing an argument list directly to subprocess with shell disabled.

Formal Syntax & Structure

python syntaxpython
import shlex

Return Value

module

Module namespace available through import; import is a statement, not a value-returning expression.

Working Example

Example Snippetpython
import shlexprint(shlex.split('report "green tea"'))
Python Reference