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 imp | |
| import sys | |
| class ErrorlessImport(object): | |
| def find_module(self, name, path): | |
| try: | |
| return TrueLoader( | |
| imp.load_module, name, *imp.find_module(name, path)) |
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
| from zmq import Context, PULL | |
| ctx = Context() | |
| sock = ctx.socket(PULL) | |
| sock.connect("tcp://localhost:5555") | |
| counter = 1 | |
| try: | |
| with open('test.txt', 'w+') as f: | |
| while True: | |
| msg = sock.recv() |
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
| from functools import wraps | |
| from inspect import getcallargs | |
| def assert_params(*contracts): | |
| _contracts = [] | |
| for contract in contracts: | |
| _contracts.append((contract, compile(contract, '', 'eval'))) | |
| def decorator(fn): |
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/Lib/python/pyrun.swg b/Lib/python/pyrun.swg | |
| index d730a2d..b9bef17 100644 | |
| --- a/Lib/python/pyrun.swg | |
| +++ b/Lib/python/pyrun.swg | |
| @@ -1056,8 +1056,9 @@ SWIG_This(void) | |
| /* #define SWIG_PYTHON_SLOW_GETSET_THIS */ | |
| -/* TODO: I don't know how to implement the fast getset in Python 3 right now */ | |
| -#if PY_VERSION_HEX>=0x03000000 |
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
| --- python/modern/xapian_wrap.cc 2011-11-28 13:23:58.000000000 -0800 | |
| +++ python/modern/xapian_wrap.cc 2011-11-28 13:24:32.000000000 -0800 | |
| @@ -2211,7 +2211,7 @@ | |
| /* #define SWIG_PYTHON_SLOW_GETSET_THIS */ | |
| /* TODO: I don't know how to implement the fast getset in Python 3 right now */ | |
| -#if PY_VERSION_HEX>=0x03000000 | |
| +#if ((PY_VERSION_HEX>=0x03000000) || defined(PYPY_VERSION)) | |
| #define SWIG_PYTHON_SLOW_GETSET_THIS | |
| #endif |
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
| class Mock(object): | |
| def __init__(self, *args, **kwargs): | |
| pass | |
| def __getattr__(self, name): | |
| return Mock() | |
| m = Mock() | |
| print m.awesome |
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
| class CowDict(dict): | |
| _shared = {} | |
| def __init__(self): | |
| self._shared = CowDict._shared | |
| self._local = {} | |
| def __getitem__(self, key): | |
| value = self._local.get(key) or self._shared.get(key) | |
| if value: |
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
| requires = '' | |
| with open('requirements.txt') as f: | |
| requires = f.read() | |
| setup(..., | |
| install_requires=requires, | |
| ) |
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 | |
| from Crypto.Cipher import Blowfish | |
| from zmq.rpc.simplerpc import ( | |
| RPCService, | |
| RPCServiceProxy, | |
| rpc_method, | |
| Serializer | |
| ) |
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
| class Values: | |
| def __init__(self, defaults=None): | |
| if defaults: | |
| for (attr, val) in defaults.items(): | |
| setattr(self, attr, val) | |
| def __str__(self): | |
| return str(self.__dict__) |