Create a gist now

Instantly share code, notes, and snippets.

Fluent interface concepts for Python
# Fluent Interface Definition
class sql:
class select:
def __init__(self, dbcolumn, context=None):
self.dbcolumn = dbcolumn
self.context = context
def select(self, dbcolumn):
return self.__class__(dbcolumn,self)
# Demo
q = sql.select('foo').select('bar')
print q.dbcolumn #bar
print q.context.dbcolumn #foo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment