Skip to main content

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


Download files

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

Source Distribution

python-polymorphism-0.1.0.tar.gz (1.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page