MCPcopy Index your code
hub / github.com/LabPy/lantz / check_membership

Function check_membership

lantz/processors.py:362–382  ·  view source on GitHub ↗

:param container: :return: >>> checker = check_membership((1, 2, 3)) >>> checker(1) 1 >>> checker(0) Traceback (most recent call last): ... ValueError: 0 not in (1, 2, 3)

(container)

Source from the content-addressed store, hash-verified

360
361
362def check_membership(container):
363 """
364
365 :param container:
366 :return:
367
368 >>> checker = check_membership((1, 2, 3))
369 >>> checker(1)
370 1
371 >>> checker(0)
372 Traceback (most recent call last):
373 ...
374 ValueError: 0 not in (1, 2, 3)
375
376 """
377
378 def _inner(value):
379 if value not in container:
380 raise ValueError('{!r} not in {}'.format(value, container))
381 return value
382 return _inner
383
384
385def get_mapping(container):

Callers 2

to_callableMethod · 0.85
to_callableMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected