Pytyp uses ABCs and function annotations in a consistent, pythonic way that supports declarative APIs - instead of saying how to do something, you have the ability to say what you want.
It includes:
A basic set of type specifications for describing collections of data, closely integrated into the language:
>>> isinstance([1,2,None,4], Seq(Opt(int))) True
A decorator that type-checks functions:
>>> def str_only(x:str): return 'foo' >>> str_only(42) Exception raised: ... TypeError: Type str inconsistent with 42.
A decorator that allows dynamic dispatch by type. You can combine multiple methods under one name, and then select which method is called by the type of an argument (normal OO programming uses the type of self to select the method; this is more like Lisp’s multimethods).
Routines for converting between Python classes and JSON or YAML. Instead of having to work with dict and list you can read JSON directly into Python classes. This is included as an example of the declarative API possible - you describe the form of the output using type specifications.
The ideas behind the library are described in more detail in Algebraic ABCs.
Note that you must also install PyYAMP if you want to encode/decode YAML.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
File details
Details for the file pytyp-2.2.1.zip.
File metadata
- Download URL: pytyp-2.2.1.zip
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c6d9157ce020d6c62ba4c332429fc2f58b4daad08213ad5e426110e7ccd7dc2
|
|
| MD5 |
a4931c39852a7abba1efd072825b2c24
|
|
| BLAKE2b-256 |
f9dabd0cfed400b74eb8eb2b8b7ac588252098acbabf290c77a3feaae9626d93
|
File details
Details for the file pytyp-2.2.1.tar.gz.
File metadata
- Download URL: pytyp-2.2.1.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4d503d066b5466842f075057c8a60b0c37653a50fc65dfd3fffe9c0765f0504
|
|
| MD5 |
f388507ac5199c0ad682bdb5cc5e8402
|
|
| BLAKE2b-256 |
f035c4d9db58e2c76546e67c2ab45ed7040d33d2dccf6830115ffa638b00cf45
|