This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import importlib.machinery | |
import importlib.util | |
import sys | |
def load_module(mod_name: str, filepath: str) -> None: | |
""" | |
Dynamically loads a Python module from the given file path and adds it to sys.modules. | |
Args: | |
mod_name (str): The name to be used for the loaded module. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pathlib import Path | |
def tail(filename: str | Path, n: int) -> str: | |
""" | |
Get the last n lines of a file. | |
Parameters: | |
- filename (str | Path): The path to the file. | |
- n (int): The number of lines to retrieve from the end of the file. |