Skip to content

Instantly share code, notes, and snippets.

@riaanvddool
Created July 25, 2012 10:05
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
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 = 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