Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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 ='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