summaryrefslogtreecommitdiff
path: root/examples/arg_printer.py
diff options
context:
space:
mode:
authorTodd Leonhardt <tleonhardt@gmail.com>2017-06-13 14:49:22 -0400
committerTodd Leonhardt <tleonhardt@gmail.com>2017-06-13 14:49:22 -0400
commit34c4f3ce4b778d95a67a7d66ed98682ba7464f67 (patch)
treed6f20d06f80c7dede07963133a7a48bb9484f2fb /examples/arg_printer.py
parent0af8018cdce37e40719e3f6c4023e9525b1e69de (diff)
downloadcmd2-git-34c4f3ce4b778d95a67a7d66ed98682ba7464f67.tar.gz
Added new pyscript command
This command is explicitly for running Python script files within an embedded Python interpreter. The advantages over the py command with "run" are: - Tab-completion of file system paths is supported - Command-line arguments can be passed to the Python script
Diffstat (limited to 'examples/arg_printer.py')
-rwxr-xr-xexamples/arg_printer.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/examples/arg_printer.py b/examples/arg_printer.py
new file mode 100755
index 00000000..42084d4e
--- /dev/null
+++ b/examples/arg_printer.py
@@ -0,0 +1,6 @@
+#!/usr/bin/env python
+# coding=utf-8
+import sys
+print("Running Python script {!r} which was called with {} arguments".format(sys.argv[0], len(sys.argv) - 1))
+for i, arg in enumerate(sys.argv[1:]):
+ print("arg {}: {!r}".format(i+1, arg))