Skip to main content

No more if else code

Project description

No more if else code

  • 示例一
from NoIf import handle_base


@handle_base.register('strategy_test')
def strategy_1():
    print('strategy_1')


@handle_base.register('strategy_test')
def strategy_2():
    print('strategy_2')

if __name__ == '__main__':
    strategy = handle_base.invoke('strategy_test', 'strategy_1')
    strategy()

  • 示例二
from NoIf import handle_base


class Strategy(object):
    pass


@handle_base.register(Strategy)
class Strategy1(Strategy):

    def test(self):
        print('strategy_1')


@handle_base.register(Strategy)
class Strategy2(Strategy):

    def test(self):
        print('strategy_2')


if __name__ == '__main__':
    strategy_handle = handle_base.invoke(Strategy, 'Strategy1')
    handle = strategy_handle()
    handle.test()

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

NoIf-0.5.0.tar.gz (2.5 kB view details)

Uploaded Source

File details

Details for the file NoIf-0.5.0.tar.gz.

File metadata

  • Download URL: NoIf-0.5.0.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.4

File hashes

Hashes for NoIf-0.5.0.tar.gz
Algorithm Hash digest
SHA256 45dee3d40115d763f301c52251bc329f778dfecad44988d9154cce450912d8b2
MD5 1eca18f76e96413acc34e7fcee6a10a4
BLAKE2b-256 28e41852126e36f9cdd720a53feebd84fe86642cd3152d11728a53a0496a9080

See more details on using hashes here.

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