@accepts decorator to check arguments types
Project description
Install
$ [sudo] pip install accepts
Features
- support multiple types argument
- support None argument
- human readable detailed exception message
Functions
function | description |
---|---|
accepts.accepts(*types) |
@accepts decorator |
Examples
>>> from accepts import accepts
>>> @accepts(int)
def inc(value):
return value+1
>>> inc(1) # ok
# multiple types
>>> @accepts((int,float))
>>> inc(1.5) # ok
>>> inc("string")
TypeError: inc() argument #0 is not instance of (<class 'int'>, <class 'float'>)
# None
>>> @accepts((int,float,type(None)))
readme-md - README.md generator
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
accepts-2018.11.19.tar.gz
(1.7 kB
view hashes)
Built Distribution
Close
Hashes for accepts-2018.11.19-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | df7d6c2fe969dda607c6d73b8390ccc9f7c497a7d24091cee5ee8e8e8eec35a6 |
|
MD5 | 8d2474d95f1ef0573bec8d50b7960b93 |
|
BLAKE2b-256 | f5b350ef8d45363f2247b5427306adc9ef0e16fb66c25e186ebd31e4f853aead |