On this page
shlex.join
Up: shlex | Next: shlex.quote
Rel: shlex.quote, shlex.shlex, shlex.split
Ref: docs.python.org — shlex.join
Tags: #public #python3 #stdlib #shlex
Import
import shlex
from shlex import join
Signature & Overview
shlex.join(split_command)
Return a shell-escaped string from split_command.
Usage
import shlex
cmd = shlex.join(['grep', '-n', 'hello world', 'notes.txt'])
assert cmd == "grep -n 'hello world' notes.txt"
Gotchas
- Safe inverse of
shlex.split()for logging or displaying shell commands (still pass the list tosubprocess.run()).
REPL Inspect
from shlex import join
help(join)
Linked from
Related notes
- 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/split 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