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

Problem calling attributes containing '-' #99

Open
mohanex opened this issue Feb 26, 2024 · 1 comment
Open

Problem calling attributes containing '-' #99

mohanex opened this issue Feb 26, 2024 · 1 comment

Comments

@mohanex
Copy link

mohanex commented Feb 26, 2024

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.

@wkta
Copy link

wkta commented Jul 24, 2024

Hello,
thanks for your comment. If I see how to improve the munch tool I will happily give it a try.

To fully understand the problem you faced :

  • What did you type to get the AttributeError exception? (Or can you provide a snippet of your source-code that raises that Exception?)

I assume you typed my_object.llm-api am I correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants