Skip to content

what-studio/valuedispatch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages