Just learning about with statements especially from this article
question is, can I pass an argument to __enter__?
I have code like this:
class clippy_runner:
def __enter__(self):
self.engine = ExcelConnection(filename = "clippytest\Test.xlsx")
self.db = SQLConnection(param_dict = DATASOURCES[STAGE_RELATIONAL])
self.engine.connect()
self.db.connect()
return self
I’d like to pass filename and param_dict as parameters to __enter__. Is that possible?
Yes, you can get the effect by adding a little more code.