skip to navigation
skip to content

placeholder 0.5

Operator overloading for fast anonymous functions.

About Placeholder

Operator overloading for fast anonymous functions.

A placeholder object uses operator overloading to create partially bound functions on-the-fly. When used in a binary expression, it will return a callable object with the other argument bound. It’s useful for replacing lambda in functional programming, and resembles Scala’s placeholders.

>>> __[key]


>>> 1 + __

>>> __ - 1

>>> -__

An F expression extends placeholders with function composition, but at a slight performance cost. They can be created explicitly from a function, or implicitly through operators as with placeholders.

>>> F(len) + 1
lambda obj: len(obj) + 1

>>> (___ * 2) + 1
lambda obj: obj * 2 + 1

__ and ___ are placeholder and F singletons which can be imported from the module, but each can of course be instantiated and bound to any desired name.

See tests for more example usage.


Standard installation from pypi or local download.

$ pip install placeholder
$ python install


Python 2.7 or 3.3+.


100% branch coverage.

$ py.test [--cov]



  • Unary operators
  • __call__ implements methodcaller
  • __getitem__ supports only single argument
  • Improved error handling
  • composer object depecated in favor of optimized F expression
File Type Py Version Uploaded on Size
placeholder-0.5.tar.gz (md5) Source 2015-09-05 4KB