Skip to content

Instantly share code, notes, and snippets.

@riaanvddool
Created July 25, 2012 10:05
Show Gist options
  • Save riaanvddool/3175416 to your computer and use it in GitHub Desktop.
Save riaanvddool/3175416 to your computer and use it in GitHub Desktop.
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