- PEP
XX
- Title
Build system abstraction for pip/conda etc
- Version
$Revision$ - Last-Modified
$Date$ - Author
Robert Collins <rbtcollins@hp.com>, Nathaniel Smith <njs@pobox.com>
- Discussions-To
distutils-sig <distutils-sig@python.org>
- Status
Draft
- Type
Standards Track
- Content-Type
text/x-rst
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
/// Inspired by failure::SyncFailure, but not identical. | |
/// | |
/// SyncError does not grant full safety: it will panic when errors are used | |
/// across threads (e.g. by threaded error logging libraries). This could be | |
/// fixed, but as we don't do that within rustup, it is not needed. If using | |
/// this code elsewhere, just hunt down and remove the unchecked unwraps. | |
pub struct SyncError<T: 'static> { | |
inner: Arc<Mutex<T>>, | |
proxy: Option<CauseProxy<T>>, |
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
pkt-get on eth0 | |
``` | |
[ 171.678486] 373.942625 [3255] netmap_init run mknod /dev/netmap c 10 53 # error 0 | |
[ 171.678530] netmap: loaded module | |
[ 191.078585] 393.342827 [1190] generic_netmap_attach Created generic NA ffff8801f913b000 (prev (null)) | |
[ 191.112529] 393.376778 [2013] netmap_do_regif lut ffffc90000ffb000 bufs 163840 size 2048 | |
[ 191.112579] 393.376827 [ 390] generic_netmap_register Generic adapter ffff8801f913b000 goes on | |
[ 191.112615] 393.376862 [ 441] generic_netmap_register RX ring 0 of generic adapter ffff8801f913b000 goes on | |
[ 191.112652] 393.376897 [ 451] generic_netmap_register TX ring 0 of generic adapter ffff8801f913b000 goes on | |
[ 191.113897] 393.378080 [ 475] generic_qdisc_init Qdisc #0 initialized with max_len = 1024 |
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
from testresources import OptimisingTestSuite | |
def load_tests(standard_tests, module, loader): | |
# top level directory cached on loader instance | |
this_dir = os.path.dirname(__file__) | |
package_tests = loader.discover(start_dir=this_dir, pattern=pattern) | |
standard_tests.addTests(package_tests) | |
return OptimisingTestSuite(standard_tests) |
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
from operator import methodcaller | |
import random | |
import itertools | |
def card_values(card): | |
"""Get the possible values of a card in a blackjack game. | |
e.g. card_values(0) -> (1, 11) | |
:return: A tuple of the possible values. | |
""" |
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 csv | |
f = open('income-distribution.csv', 'rt') | |
l = list(csv.reader(f)) | |
pre = l[5:157] | |
# top edge, lower edge, % | |
brackets = [(14000, 0, 0.105), (48000, 14001, 0.175), (70000, 48001, 0.30), (200000, 70001, 0.33)] | |
total = 0 | |
for (_, people, total_income, _) in pre: | |
people = float(people) | |
total_income = float(total_income) * 1000000 |
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 HandleEvent(testtools.StreamResult): | |
def __init__(self, callback): | |
self._buffers = {} | |
self._callback = callback | |
def status(self, test_id=None, test_status=None, test_tags=None, | |
runnable=True, file_name=None, file_bytes=None, eof=False, | |
mime_type=None, route_code=None, timestamp=None): | |
if not test_id: | |
return |
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
from ctypes import * | |
pythonapi.PyDict_SetItemString.argtypes=[c_void_p, c_char_p, c_void_p] | |
class PyObject(Structure): | |
_fields_ = [("refcnt", c_size_t), | |
("typeid", c_void_p)] | |
pythonapi.PyThreadState_GetDict.restype = POINTER(PyObject) | |
pythonapi.PyDict_SetItemString(c_void_p(id(locals())), b"threaddict", pythonapi.PyThreadState_GetDict()) | |
repr([1]) | |
print(threaddict) |
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
PyMonad | |
https://pypi.python.org/pypi/PyMonad/ | |
Doesn't duck type Writer - subclass | |
class StringWriter(Writer): | |
logType = str | |
PyMonads | |
https://github.com/dustingetz/pymonads | |
Doesn't duck type Writer: | |
https://github.com/dustingetz/pymonads/blob/master/writer.py#L6 |
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
//Copy this over the contents at tddbin.com | |
//Replace the [] in the assert statements with a functional equivalant | |
//Reference here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array | |
//Lambda syntax: (x,y) => x + y, works in firefox, try it out :) | |
function range(start, end, jump) { | |
jump = jump || 1 | |
if (start && !end) | |
return actualRange(0, start, jump) | |
return actualRange(start, end, jump) |
NewerOlder