Skip to content

Instantly share code, notes, and snippets.

View cjw296's full-sized avatar

Chris Withers cjw296

View GitHub Profile
from collections import defaultdict
import re
order = 'ID', 'GE', 'FN', 'LN','MN', 'EM', 'ST'
MAX_NUM = int(input ("Please enter the number of records: "))
records = []
while len(records) < MAX_NUM:
new_records = input("Please enter some records separated by ';' or '!': ")
for record in re.split('[!;]', new_records):
dna_to_rna = {'A': 'U', 'C':'G', 'G':'C', 'T': 'A'}
def transcribe(d):
return ''.join(dna_to_rna.get(e, '') for e in d)
def dot(l, k):
if len(l) != len(k):
return 0
if not (l or k):
return 0
return l[0]*k[0] + dot(l[1:], k[1:])
def dot(l, k):
if len(l) != len(k):
return 0
return sum(a*b for a, b in zip(a, b))
def pytest_what_name_goes_here(...):
for item in get_items_from('../docs/*.rst'):
yield item
____________________________________________________________________________________________ test_compare_fail_for_pytest _____________________________________________________________________________________________
def test_compare_fail_for_pytest():
> compare({'x': 1}, {'x': 2})
testfixtures/tests/test_compare.py:1379:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
args = ({'x': 1}, {'x': 2}), kw = {}, prefix = None, suffix = None, raises = True, context = <testfixtures.comparison.CompareContext object at 0x103f5cdd8>, x = {'x': 1}, y = {'x': 2}
message = "dict not as expected:\n\nvalues differ:\n'x': 1 != 2"
@cjw296
cjw296 / gist:6384d1e0e9d2a4d14085
Last active April 21, 2016 17:19
Voluptuous double validate trick
# schema as follows, currently:
>>> schema = Schema({'logging': {Required('file_level', default='info'): str,
... Required('console_level', default='info'): str}})
# this works as desired:
>>> schema({'logging': {'file_level': 'warning'}})
{'logging': {'file_level': 'warning', 'console_level': info'}}
# this doesn't:
>>> schema({}})
Listening for transport dt_socket at address: 8000
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building ShiningPanda Plugin 0.22-SNAPSHOT
[INFO] ------------------------------------------------------------------------