This file contains 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
# Copied from http://etienned.github.io/posts/extract-text-from-word-docx-simply/ | |
try: | |
from xml.etree.cElementTree import XML | |
except ImportError: | |
from xml.etree.ElementTree import XML | |
import zipfile | |
""" |
This file contains 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 matplotlib.pyplot as plt | |
from functools import partial | |
set_title = partial(plt.suptitle, fontweight='bold', fontsize=12) |
This file contains 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
# Taken from: https://zapier.com/engineering/profiling-python-boss/ | |
import time | |
class timewith(): | |
def __init__(self, name=''): | |
self.name = name | |
self.start = time.time() | |
@property |
This file contains 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
# Taken from: https://zapier.com/engineering/profiling-python-boss/ | |
import cProfile | |
def do_cprofile(func): | |
def profiled_func(*args, **kwargs): | |
profile = cProfile.Profile() | |
try: | |
profile.enable() | |
result = func(*args, **kwargs) |
This file contains 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
# Taken from: https://zapier.com/engineering/profiling-python-boss/ | |
try: | |
from line_profiler import LineProfiler | |
def do_profile(follow=[]): | |
def inner(func): | |
def profiled_func(*args, **kwargs): | |
try: | |
profiler = LineProfiler() |
This file contains 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 func(): | |
... print 'hello' | |
... | |
>>> from functools import partial | |
>>> def func(str_): | |
... print str_ | |
... | |
>>> f = partial(func, 'world') | |
>>> f | |
<functools.partial object at 0x9fddf04> |
This file contains 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
>>> class Foo(object): | |
... def a(self): return 'a' | |
... | |
>>> x = Foo() | |
>>> print x.a() | |
a | |
>>> | |
>>> def b(self): | |
... return 'b' | |
... |
This file contains 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 | |
>>> x = numpy.arange(27).reshape((3,3,3)) | |
>>> x | |
array([[[ 0, 1, 2], | |
[ 3, 4, 5], | |
[ 6, 7, 8]], | |
[[ 9, 10, 11], | |
[12, 13, 14], | |
[15, 16, 17]], |
This file contains 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 func_1(): | |
return ['a', 'b', 'c'] | |
def func_2(): | |
""" | |
>>> func_1() | |
['a', 'b', 'c'] | |
""" | |
pass |
This file contains 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
C0102: Black listed name "%s" | |
C0103: Invalid %s name "%s" | |
C0111: Missing %s docstring | |
C0112: Empty %s docstring | |
C0121: Missing required attribute "%s" | |
C0202: Class method %s should have cls as first argument | |
C0203: Metaclass method %s should have mcs as first argument | |
C0204: Metaclass class method %s should have %s as first argument | |
C0301: Line too long (%s/%s) | |
C0302: Too many lines in module (%s) |