Skip to content

Instantly share code, notes, and snippets.

@2tony2
Created May 22, 2024 07:38
Show Gist options
  • Select an option

  • Save 2tony2/fcc6070a4083a6c31cad903da29866cd to your computer and use it in GitHub Desktop.

Select an option

Save 2tony2/fcc6070a4083a6c31cad903da29866cd to your computer and use it in GitHub Desktop.
from typing import Optional
def process_data(file_path: str, delimiter: Optional[str] = None) -> str:
delimiter_info = f" with delimiter '{delimiter}'" if delimiter else ""
return f"Processing file at {file_path}{delimiter_info}"
print(process_data("/path/to/file.csv")) # Output: Processing file at /path/to/file.csv
print(process_data("/path/to/file.csv", ",")) # Output: Processing file at /path/to/file.csv with delimiter ','
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment