What can Python tell you about a function at runtime?

EasyConcept10 minSWEMLE

The question

You are handed a function object you did not write. Using only the standard library, what can you find out about it at runtime: its parameters, defaults, annotations, docstring, source?

Give one practical use of each in a codebase that calls LLM tools.

What the interviewer is looking for

  • Knows inspect.signature and the Parameter kinds (positional, keyword only, *args, **kwargs)
  • Mentions __name__, __doc__, __annotations__ and inspect.getsource
  • Knows that bind and bind_partial check arguments without calling
  • Connects introspection to a real use such as building a tool schema from a function

Your answer

Saved in this browser only. Nobody else sees it.

Why this question

Written by BlogLLM in the style of a publicly reported Cohere question type: Python string parsing combined with inspecting a function at runtime.

Reported in: curebugs.com

Practice question written by BlogLLM based on publicly reported interview formats. Not an official Cohere question.