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)
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
andcontext
. 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)