0 votes
1 view
in Data Science by (18.3k points)

The context is complex to explain, but tl;dr I have to deal with the production system where I cannot install libraries and one of my libraries expects illegal keyword arguments as the input.

def hack_me(**kwargs):

   if kwargs.get("hack:/me") is not None:

      print("Hacked!")

The objective is that my function above, without modifying it, prints Hacked!.

1 Answer

0 votes
by (36.8k points)

While your regular arguments can't have any form for their name, expanded arguments using a same syntax as in the function signature (i.e. **args) can.

>>> args = {'hack:/me': True}

>>> hack_me(**args)

Hacked!

Want to be a Data Science expert? Come and join this Data Science Courses

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...