Skip to content

Problem calling attributes containing '-' #99

Description

@mohanex

Hello,

I have been using the Munch library for a while now.
On my python code, I imported some parametrs from an YAML file and then tried to iterate on them one by one. The problem is that some parametrs with the '-' caracter are not accepted and my python 3.11.7 throws :

Traceback (most recent call last):
  File "PATH\venv\Lib\site-packages\munch\__init__.py", line 116, in __getattr__
    return object.__getattribute__(self, k)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Munch' object has no attribute 'llm'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "PATH\venv\Lib\site-packages\munch\__init__.py", line 119, in __getattr__
    return self[k]
KeyError: 'llm'

My key is llm-api but the Munch object does just recongnize llm and not the rest of the key.
Is this a common problem?

PS : I resolved this issue by replacing '-' to '_' on my YAML file and it works perfectly, otherways I just want to report this because it made me crazy for some hours and also to help some beautiful lost soul in the future.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions