I use if__name__main__ often when working with AWS Lambda, but I also want to run it locally. Lambda wants to call a function with the params event and context. So I would do something like this:
def handler(event, context):
things
return {
'statusCode': 200,
'body': 'Hello from Lambda!'
}
if __name__ == '__main__':
event = {}
context = {}
response = handler(event, context)
print(response)
Yeah. I like using main() that way too. It's usually just a high-level function that handles globals relevant to running in standalone and calling other functions to do work.