Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (18.4k 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

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...