Skip to content

Instantly share code, notes, and snippets.

@Lucas-C
Created August 24, 2015 20:51
Show Gist options
  • Save Lucas-C/4f466b14061c5fbfbbd8 to your computer and use it in GitHub Desktop.
Save Lucas-C/4f466b14061c5fbfbbd8 to your computer and use it in GitHub Desktop.
Patch to document the changes detailed in https://github.com/amoffat/sh/issues/269
--- index.txt 2015-08-24 22:48:41.587933500 +0200
+++ index.txt.new 2015-08-24 22:41:03.269527000 +0200
@@ -381,6 +381,20 @@
print(myserver.tail("/var/log/dumb_daemon.log", n=100))
+.. _special_arguments_defaults:
+
+Special arguments defaults
+--------------------------
+
+You can set the default values of all the :ref:`special keyword argument <special_arguments>`,
+by using the `defaults` context manager:
+
+ import sh, sys
+ with sh.defaults(_out=sys.stdout):
+ from sh import echo
+ echo('HELLO WORLD!') # prints to stdout
+
+
.. _with_contexts:
'With' contexts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment