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
| diff --git a/pycco b/pycco | |
| index aaabb7b..bbe1b04 100755 | |
| --- a/pycco | |
| +++ b/pycco | |
| @@ -163,6 +163,7 @@ languages = { | |
| ".py": { "name": "python", "symbol": "#" }, | |
| ".scm": { "name": "scheme", "symbol": ";;" }, | |
| ".lua": { "name": "lua", "symbol": "--" }, | |
| + ".erl": { "name": "erlang", "symbol": "%%" }, | |
| } |
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
| def debug(s, *args, **kwargs): | |
| c_frame = inspect.getouterframes(inspect.currentframe(), 1)[1][0] | |
| c_args, c_varargs, c_varkw, c_locals = inspect.getargvalues(c_frame) | |
| d = dict(c_locals) | |
| if kwargs: d.update(kwargs) | |
| print s.format(*args, **d) | |
| def foo(): | |
| bar = 'world' | |
| debug('hello {bar}') |
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
| """ | |
| Implementation of the Extrinsic Visitor Pattern in Python with support | |
| for Inheritance. | |
| see: http://peter-hoffmann.com/2010/extrinsic-visitor-pattern-python-inheritance.html | |
| """ | |
| class Node(object): pass | |
| class A(Node): pass | |
| class B(Node): pass |
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 lxml.etree | |
| def pprint(elem): | |
| print lxml.etree.tostring(elem, pretty_print=True) | |
| class Bind(object): | |
| def __init__(self, path, converter=None, first=False): | |
| ''' | |
| path -- xpath to select elements | |
| converter -- run result through converter | |
| first -- return only first element instead of a list of elements |
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 lxml.etree | |
| def pprint(elem): | |
| print lxml.etree.tostring(elem, pretty_print=True) | |
| class Bind(object): | |
| def __init__(self, path, converter=None, first=False): | |
| ''' | |
| path -- xpath to select elements | |
| converter -- run result through converter | |
| first -- return only first element instead of a list of elements |
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 time | |
| class Retry(object): | |
| default_exceptions = (Exception) | |
| def __init__(self, tries, exceptions=None, delay=0): | |
| """ | |
| Decorator for retrying function if exception occurs | |
| tries -- num tries | |
| exceptions -- exceptions to catch |