Box
Box copied to clipboard
box_dots does not support keys including numbers
Windows 7, Python 3.7.3, Box 4.0.3
#!/usr/bin/env python3
import box
info = box.Box({'uno': {2: 'tres', 'cuatro': 5}}, default_box=True, box_dots=True)
print(info['uno'][2])
# tres
print(info['uno.2'])
# {}
# it should be:
# tres
print(info['uno']['cuatro'])
# 5
print(info.uno.cuatro)
# 5
print(info['uno.cuatro'])
# 5
While this would be a nice to have, that would be very costly to try and convert all keys to do string lookups on. At minimum I need to mention that limiting factor in the readme for now.
Please note that keys starting with numbers don't work in Box either. In my case I was using 25percent changing key to p25percent DID work
Keys including "-" don't work either. I had to replace "-" with "_".
@MrBillium @luckyp70 do you have code samples you can share? I am not able to duplicate.
from box import Box
my_box = Box(box_dots=True)
my_box['22test'] = {'33-test': {'sub2': 'a'}}
print(my_box)
# {'22test': {'33-test': {'sub2': 'a'}}}
print(my_box['22test.33-test.sub2'])
# a