benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf e1dfd688-152d-50f8-b63d-39d9f5cec6f4

Problem

Answer published by the source. Consult the official source to check your work against its answer.

complete prompt

import inspect
import types
import json

def task_func(f):
    """
    Inspects the given function 'f' and returns its specifications as a JSON string. This includes
    the function's name, arguments, default values, annotations in a string format, and a boolean
    indicating if it's a lambda function.

    Parameters:
    f (function): The function to inspect.

    Returns:
    str: A JSON string containing the function's specifications.

    Requirements:
    - inspect
    - types
    - json

    Examples:
    >>> def sample_function(x, y=2): return x + y
    >>> 'sample_function' in task_func(sample_function)
    True
    >>> def sample_function2(x, y=2): return x * y
    >>> 'sample_function2' in task_func(sample_function2)
    True
    """

instruct prompt

Inspects the given function 'f' and returns its specifications as a JSON string. This includes the function's name, arguments, default values, annotations in a string format, and a boolean indicating if it's a lambda function.
The function should output with:
    str: A JSON string containing the function's specifications.
You should write self-contained code starting with:

Code

import inspect
import types
import json
def task_func(f):

code prompt

Code

import inspect
import types
import json
def task_func(f):

entry point

task_func

libs

  • types
  • inspect
  • json

Discussion

Discussion

No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

Source and history

Official source

initial import