benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 4f1cc777-7fdf-55ff-8f2d-61c7c0c64ca6

Problem

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

complete prompt

import os
import shutil
import fnmatch

def task_func(source_directory, destination_directory, file_pattern):
    """
    Moves all files that match a particular pattern from one directory to another.
    
    Functionality:
    - Moves files from 'source_directory' to 'destination_directory' based on a filename pattern 'file_pattern'.
    
    Parameters:
    - source_directory (str): The path to the source directory from which files will be moved.
    - destination_directory (str): The path to the destination directory to which files will be moved.
    - file_pattern (str): The file pattern to match (e.g., '*.txt' for all text files).
    
    Returns:
    - Returns a list of filenames that were moved.
    
    Requirements:
    - os
    - shutil
    - fnmatch
    
    Example:
    >>> task_func('/path/to/source', '/path/to/destination', '*.txt')
    ['task_func_data/file1.txt', 'task_func_data/file2.txt']
    """

instruct prompt

Moves all files that match a particular pattern from one directory to another. Functionality: - Moves files from 'source_directory' to 'destination_directory' based on a filename pattern 'file_pattern'.
The function should output with:
    Returns a list of filenames that were moved.
You should write self-contained code starting with:

Code

import os
import shutil
import fnmatch
def task_func(source_directory, destination_directory, file_pattern):

code prompt

Code

import os
import shutil
import fnmatch
def task_func(source_directory, destination_directory, file_pattern):

entry point

task_func

libs

  • shutil
  • fnmatch
  • os

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