Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Easily curry multiple functions to a given list of arguments without using classes

Project Description

Get all the benefits of making your functions methods on a class
without actually having define them methods on a class!

**Classless** allows you, instead,
to pass a list of functions to ```gen_class```
and curry them on the specified attributes.


.. code-block:: python

from classless import gen_class

def fun_stuff(db, name, x):
q = db.get(name)
return int(q) + x

def cool_stuff(q, z, name, y, db):
db.insert(name, (q, z, y))

def awesome_adventure(w, name):
if w > 5:
return name
raise Exception("I don't approve of the name {}".format(name))

MyPretendClass = gen_class(methods=(fun_stuff,
init_attrs=['db', 'name'])

and then we use ``MyPretendClass`` just like any regular class:

.. code-block:: python

obj = MyPretendClass(name='NiceName', db=some_connection)
obj.awesome_adventure(25) # Calls awesome_adventure with name='NiceName'
# and w=25

obj.cool_stuff(1,2,3) # == cool_stuff(1, 2, 'NiceName', 3, some_connection)

obj.fun_stuff('Dr. X') # == fun_stuff(x='Dr. X', name='NiceName',
# db=some_connection)
where ``obj`` just holds the list of ``methods`` curried on the ``init_attrs``.

We could have defined ``MyRealClass`` as so and get identical behaviour:

.. code-block:: python

class MyRealClass(object):
def __init__(self, db, name):
self.db = db = name

def fun_stuff(x):
q = self.db.get(
return int(q) + x

def cool_stuff(q, z, y):
self.db.insert(, (q, z, y))

def awesome_adventure(w):
if w > 5:
raise Exception("I don't approve of the name {}".format(

But, then every one of those methods is tied down to a given class, and can't be used as regular functions, without first constructing ``MyRealClass``.
Release History

Release History

This version
History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
Classless-0.0.2.tar.gz (3.2 kB) Copy SHA256 Checksum SHA256 Source Sep 26, 2013

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting