Skip to content

JaysenLeo/NoIf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

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()

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages