what-studio / valuedispatch

Dispatches value by singledispatch-like API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

valuedispatch

singledispatch-like API but dispatches value instead of type.

[![Build Status] (https://travis-ci.org/what-studio/valuedispatch.svg)] (https://travis-ci.org/what-studio/valuedispatch) [![Coverage Status] (https://img.shields.io/coveralls/what-studio/valuedispatch.svg)] (https://coveralls.io/r/what-studio/valuedispatch)

@valuedispatch
def encode(encoding, text):
    return text.encode(encoding)

@encode.register('base32')
def encode_base32(encoding, text):
    return base64.b32encode(text.encode('utf-8'))

encode('utf-8', u'Hello, world')
encode('base32', u'Hello, world')

Written by Heungsub Lee at What! Studio in Nexon, and distributed under the BSD 3-Clause license.

About

Dispatches value by singledispatch-like API

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Python 100.0%