I am experimenting with fluent interfaces in Python.
An example of a fluent sql query generator would look something like this in usage:
sql.select('foo').select('bar').from('sometable').tostring()
I quickly realized that the ability to define nested classes recursively would probably help.
class sql:
class select:
class select # <-- HERE
def __init__(self, dbcolumn, astype=None, asname=None):
self.dbcolumn = dbcolumn
self.astype = astype
self.asname = asname
In the line marked with the comment '# <-- HERE':
I want this nested class reference to refer to the same 'select' class definition of the containing class.
Is this possible somehow? Maybe using some keyword that I am not aware of?