'pyoverload' overloads the functions by simply using typehints and adding decorator '@overload'.
Project description
pyoverload
pyoverload
is a package affiliated to project pyctlib
. It is a powerful overloading tools to provide easy overload for python v3.6+
. pyoverload
provide multiple usages. The simplest one, however, can be easily implemented as follows.
>>> from pyoverload import overload
>>> @overload
... def func(x: int):
... print("func1", x)
...
>>> @overload
... def func(x: str):
... print("func2", x)
...
>>> func(1)
func1 1
>>> func("1")
func2 1
pyoverload
has all of following appealing features:
- Support of
Jedi
auto-completion by keyword decorator@overload
. This means all main-stream python IDE can hint you the overloaded functions you have defined. - Multiple usages that are user friendly for all kinds of users, including
C/Java
language system users and those who are used tosingledispatch
based overload. Also, easy collector of ordinary python functions is also provided. - Support of all kinds of functions, including functions, methods, class methods and static methods. One simple implementation for all.
- String types supported. This means that one can use
"numpy.ndarray"
to mark a numpy array without importing the whole package. - Sufficient built-in types are provided for easy representations such as
List[Int]
,Dict@{str: int}
orList<<int>>[10]
. - Available usage listing when no overload function matches the input arguments.
- Type constraint for an ordinary function using
@params
decorator.
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
pyoverload-0.5.7.tar.gz
(12.7 kB
view hashes)