Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update utils.py #111

Closed
wants to merge 1 commit into from
Closed

Commits on Nov 3, 2024

  1. Update utils.py

    1. **What it Does**:  
       The function takes a dictionary (which could have nested dictionaries and lists inside it) and turns it into a readable, formatted string. It lets you choose which keys to ignore and adjusts indentation based on the depth of nesting.
    
    2. **Handling Inputs**:
       - It avoids issues with mutable defaults by setting `ignore` to an empty list if none is provided.
       - `depth` controls how much indentation each level gets, so deeper levels appear visually indented in the final string.
    
    3. **Efficiency**:
       - Instead of constantly building a single large string (which can be slow for large dictionaries), it collects lines in a list and joins them at the end, making the function faster.
    
    4. **Handling Different Data Types**:
       - Lists are formatted as comma-separated values.
       - Nested dictionaries are handled with recursion, making sure each nested level gets formatted properly without cluttering the main function.
    
    5. **Readability Improvements**:
       - It uses modern string formatting (f-strings) for clarity.
       - It leaves dictionary key capitalization as-is, giving the output a more natural look.
    akshitbansal2005 authored Nov 3, 2024
    Configuration menu
    Copy the full SHA
    fd57ebd View commit details
    Browse the repository at this point in the history