This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set laststatus=2 | |
set statusline=%<%F%=\ [%M%R%H%Y]\ (%(%l,%c%)) | |
syntax on | |
set autoindent | |
set tabstop=4 | |
set shiftwidth=4 | |
set smarttab | |
set expandtab | |
set softtabstop=4 | |
autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If you don't need streaming stdout, just use communicate to access stdout and stderr instead | |
import threading | |
import subprocess | |
import sys | |
pr = subprocess.Popen(['command'], env=my_env, | |
stdin=subprocess.PIPE, stdout=subprocess.PIPE, | |
stderr=subprocess.STDOUT) | |
def pipe_writer(): | |
pr.stdin.write(input) | |
pr.stdin.close() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
A = np.matrix([[1, 2], [3, 4]]) | |
A[0,:].nonzero() # Returns (matrix([[0, 0]]), matrix([[0, 1]])) if np.__version__ == "1.8.2" | |
# Returns (array([0, 0]), array([0, 1])) if np.__version__ == "1.11.0" | |
np.asarray(A[0,:]).nonzero() # Returns (array([0, 0]), array([0, 1])) for both versions, so is backwards compatible |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import contextlib | |
@contextlib.contextmanager | |
def output_wrapper(): | |
save_stdout = sys.stdout | |
save_stderr = sys.stderr | |
sys.stdout = open('stdout.log', 'a') | |
sys.stderr = open('stderr.log', 'a') | |
yield | |
sys.stdout = save_stdout |