I have this lambda handler
def lambda_handler(event, context):
args = json.loads(event['data'][0]['body'])
batch = args['batch']
execute_ecg_batch(batch)
The execute_ecg_batch
batch function exist in the same file and has bunch of functionality that is focused towards business logic. Once done, it needs to write to Google Sheets. The google sheets depends on some params from args
object in lambda_handler
.
If my GoogleSheet
is basically a separate class whose object is created like this
gsheet_writer = GoogleSheetWriter(args.param1, arg.param2, args.param3)
How should i “structure” my code in pythonic way?
One thought is that i can greate a gsheet_writer
object in lambda_handler
and pass it through. Then it needs to pass everywhere.
If i create it globally then it wouldn’t have access to args
at the time of creation and my code has to make sure that it sets those values before it gets created.
Thoughts?