Skip to content

default_box does not work with box_dots #192

@Rexbard

Description

@Rexbard

This behaviour is noted in the Wiki, but I don't agree it is as it should be.

Using default_box, one can create and modify a new dotted chain as expected:

>>> b=Box(default_box=True)
>>> b.a.b.c = 1
>>> print(b)
<Box: {'a': {'b': {'c': 1}}}>
>>> b["a.b.c"] = 2
>>> print(b)
<Box: {'a': {'b': {'c': 2}}}>

However, when trying to create a new value using box_dots, it does not work as I expect (again the demonstrated behavior is noted in the Wiki).

>>> b=Box(default_box=True, box_dots=True)
>>> b["a.b.c"] = 1
>>> print(b)
<Box: {'a.b.c': 1}>

By declaring box_dots=True the programmer has explicitly stated they want to interpret the periods as field separators. It seems that the above code should return the same as the first code block.

Since I require this behavior, I have to split the index string and create empty boxes, then perform the b["a.b.c"]=1 for it to work as intended.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions