-1

For example, a python AWS lambda, the documented signature is:

def handler(event, context):

But the following is valid python syntax:

def handler(event, context, *args, **kwargs):

I've tested this and the lambda does not crashes. (BTW default arguments is also valid)

This would allow, for example, to decorate the handler function and then introduce extra arguments to the function. Think about a dependency injection scenario for example.

Is 'altering' the default signature considered bad practice in any way, and if so, in which way?

Javier Novoa C.
  • 11,257
  • 13
  • 57
  • 75

1 Answers1

1

This is entirely up to you, you could even do:

def lambda_handler(*args, **kwargs):

with event and context then being args[0] and args[1] respectively.

Lambda only cares that the lambda handler function takes at least two positional arguments.

Paolo
  • 21,270
  • 6
  • 38
  • 69