addict icon indicating copy to clipboard operation
addict copied to clipboard

Suggestion on attributes containing dashes

Open aellwein opened this issue 3 years ago • 0 comments

Consider this example:

>>> a = addict.Dict({'test-id': 123})
>>> a.test-id
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for -: 'Dict' and 'builtin_function_or_method'

Improvement suggestion: as for me, it would be nice if addict would support a.test_id (i.e. replace dashes with underscores in attribute names, like for example, argparse does for options).

Or even better: give user a possibility to define a replacement set or provide a callback function for it.

aellwein avatar Jul 14 '21 11:07 aellwein