Skip to content

koji-kojiro/funcall

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WIP

funcall

UFCS for Python.

An implementaion of UFCS(Uniform function call syntax) for Python. This package allows any function to be called using the syntax for member accessing. An object wrapped the funcall.obj function becomes to accept any function as its own member. The object is converted to a funcall.ChainableObject, but it behaves as expected.

from funcall import obj

x = obj(5).range.sum
# This is equivalent to;
# x = sum(range(5))

y = x + 5
# x is a ChainableObject, but behaves as int.

Installation

funcall has no dipendencies.

$ sudo pip install funcall

Usage

ChainableObject.map, filter, reduce

Implementations as methods of builtiin-functions. Arguments passed to them should be callable objects.

from funcall import obj

obj('pen pineapple apple pen').split.map(str.capitalize)
# This is equivalent to;
map(str.capitalize, 'pen pinapple apple pen'.split())

ChainableObject.call

A method which calls function passed as an argument. This is useful when using anonymous functions or functions bound to different namespaces.

from funcall import obj

obj('pen pineapple apple pen').split.call('-'.join)
# This is equivalent to;
'-'.join('pen pineapple apple pen'.split())

import numpy as np

obj(5).call(np.arange)
# This is equivalent to;
np.arange(5)
# obj(5).np.arange does'nt work...

About

UFCS for Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages