Skip to content

Instantly share code, notes, and snippets.

@bodiam
Forked from riaanvddool/fluent-python.py
Created September 23, 2013 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bodiam/6671733 to your computer and use it in GitHub Desktop.
Save bodiam/6671733 to your computer and use it in GitHub Desktop.
# 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