On this page
shlex.split
Prev: shlex.shlex | Up: shlex
Rel: shlex.join, shlex.quote, shlex.shlex
Ref: docs.python.org — shlex.split
Tags: #public #python3 #stdlib #shlex
Import
import shlex
from shlex import split
Signature & Overview
shlex.split(s, comments=False, posix=True)
Split the string s using shell-like syntax.
Usage
import shlex
assert shlex.split('git commit -m "fix bug"') == ['git', 'commit', '-m', 'fix bug']
Gotchas
- Raises
ValueErroron unmatched quotes: Passcomments=Trueif#comments should be stripped.
REPL Inspect
from shlex import split
help(split)
Linked from
Related notes
- tuts/python3/stdlib_module/shlex/join Linked here; links to this page; shared tags: #shlex, #stdlib
- tuts/python3/stdlib_module/shlex/quote Linked here; links to this page; shared tags: #shlex, #stdlib
- tuts/python3/stdlib_module/shlex/shlex Linked here; links to this page; shared tags: #shlex, #stdlib
- tuts/python3/stdlib_module/shlex links to this page; shared tags: #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib
- tuts/c/stdlib/assert/assert shared tags: #stdlib
- tuts/c/stdlib/assert/static_assert shared tags: #stdlib
- tuts/c/stdlib/ctype shared tags: #stdlib
- tuts/c/stdlib/ctype/isalpha shared tags: #stdlib