Skip to main content
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
<http://www.acooke.org/pytyp.pdf>`_.

Note that you must also install `PyYAML
<https://pypi.python.org/pypi/PyYAML>`_ if you want to encode/decode YAML.

Warning: This package is unused and largely unmaintained. Python went
in a `different direction<https://www.python.org/dev/peps/pep-0484/>`_
with types.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

pytyp-2.2.3.zip (6.2 kB view details)

Uploaded Source

pytyp-2.2.3.tar.gz (3.1 kB view details)

Uploaded Source

File details

Details for the file pytyp-2.2.3.zip.

File metadata

  • Download URL: pytyp-2.2.3.zip
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pytyp-2.2.3.zip
Algorithm Hash digest
SHA256 2dc4af91631c987dcb12076417ff7c22b03280f15fd2979f0f7c4314ab588a3b
MD5 222e3731fcbc0fc818d3aa7387920563
BLAKE2b-256 f7053aac69c43e27e72d84d524977a428af29a5bf9598312caecfa8a2e803e50

See more details on using hashes here.

File details

Details for the file pytyp-2.2.3.tar.gz.

File metadata

  • Download URL: pytyp-2.2.3.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pytyp-2.2.3.tar.gz
Algorithm Hash digest
SHA256 f3fa384cfddeb902be6d9b6d937ee988827b0649acb2c579cf8218114d9acacd
MD5 23954cd7e949183f78eb5b2229f935dc
BLAKE2b-256 139f466ed61e244f80a028ce5e053bc2535c655f7980450577adbe475c09ad80

See more details on using hashes here.

Release history Release notifications | RSS feed

2.2.4

2 files

This release

2.2.3 This release

2 files

2.2.2

2 files

2.2.1

2 files

2.2

2 files

2.0.1

2 files

2.0

2 files

1.1

2 files

1.0.2

2 files

1.0.1

2 files

1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page