- Source
p,virtualenv.zsh,auto-workon.shin your.zshrc - Put
_pin your fpath. (e.g.,/usr/share/zsh/site-functions) - Change
PYTHONPROJECTSinvirtualenv.zshto the base directory for your Python projects. - Now you can use
pto get to a project and switch to its virtualenv andpalone to deactivate your virtualenv entirely. Plus you now have tab completion into your projects - yay!
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, os, imp | |
| filepath = os.path.abspath(sys.argv[1]) | |
| mod_name = os.path.splitext(filepath)[0] | |
| user_mod = imp.load_source(mod_name, filepath) | |
| check_sudoku = user_mod.check_sudoku | |
| solve_sudoku = user_mod.solve_sudoku | |
| # Then just run it, e.g. with do_test(check_sudoku, solve_sudoku) | |
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
| # In an actual use case, pkg1 and pkg2 would be packages, | |
| # but to make this runnable I used classes | |
| # to make a namespace instead (same idea regardless) | |
| # make a dummy class so we can use it as a namespace | |
| class Dummy(object): pass | |
| pkg1, pkg2 = Dummy(), Dummy() | |
| pkg1.average = lambda *args : sum(args) * 1.0 / len(args) | |
| pkg2.get_lengths = lambda *args : map(len, args) |
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 os | |
| PATH = path/to/my/blueprints/directory | |
| BLUEPRINT = 'the_blueprint' | |
| def import_file(path, name=None): | |
| """ imports a file with given name and path """ | |
| # use the imp module to do actual imports | |
| import imp | |
| name = name or os.path.split(path)[-1].replace(".", "_") |
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
| # grab guard from https://github.com/guard/guard to use this file. | |
| # Place it in the toplevel of the pandas repo and it'll just work for you. | |
| def python_test(testpath) | |
| base = "nosetests -A \"not slow\"" | |
| if testpath.nil? | |
| puts "Running all non-slow tests" | |
| return `#{base}` | |
| else | |
| puts "Running test on #{testpath}" | |
| if !File.exists? testpath |
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 inspect | |
| import os | |
| def trace(f, indent_level=[0]): | |
| """ | |
| slap this on a function as a decorator and | |
| it'll show you what it's called with | |
| and what it returns. | |
| As an aside, if you put this on classes, be sure to |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.