A simple utility library that allow you to use OOP Like Polymorphic Function in python
Project description
What this repository contains
A simple utility library that allow you to use OOP Like Polymorphic Function in python
Installation:
install the package
pip install python-polymorphism
How to use
In a Class module
from python_polymorphism import Poly
polymorphic = Poly()
class PolyClass():
@polymorphic.this()
def test_poly_fn(self, my_first_test_argument):
return 'my_first_test_argument'
@polymorphic.this()
def test_poly_fn(self, my_second_test_argument):
return 'my_second_test_argument'
print(PolyClass().test_poly_fn(my_first_test_argument=1)) # => 'my_first_test_argument'
print(PolyClass().test_poly_fn(my_second_test_argument=1)) # => 'my_second_test_argument'
Constraints
- It works on python class only;
- The polymorphed function has to be called with kwargs;
- Default parameters do not help differentiate one function from another.
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
File details
Details for the file python-polymorphism-0.1.0.tar.gz.
File metadata
- Download URL: python-polymorphism-0.1.0.tar.gz
- Upload date:
- Size: 1.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe1ad1fe966c51ecb30e80d89ec10cea753b286061054011acdf6ce4f3b8575e
|
|
| MD5 |
eea9174f4adc274266b8a9dd2379dc32
|
|
| BLAKE2b-256 |
b4b7c940a481748e4df93549610248011ff337e01f86e67325ab88d154bad2a6
|