Skip to content

Commit 98dfc80

Browse files
committed
docs
1 parent 3d90143 commit 98dfc80

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

docs/contents/getting-started.rst

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ Inheritence
4141
Setting or assigning values
4242
---------------------------
4343

44-
Instead of raising an :code:`AttributeError`, reading a new attribute on an :code:`easytree.dict` creates and returns a new child :code:`Node`.
44+
Instead of raising an :code:`AttributeError`, reading a new attribute on an :code:`easytree.dict` returns a new :code:`undefined` node.
4545

4646
.. code-block::
4747
4848
>>> tree = easytree.dict()
49-
>>> tree.address # new undefined node
50-
<Node 'address'>
49+
>>> tree.address # undefined node
50+
<undefined 'address'>
5151
52-
Reading or setting an attribute on such child node dynamically *casts* it as an :code:`easytree.dict`.
52+
Reading or setting an attribute on such child node dynamically *casts* it as an :code:`easytree.dict` and assigns it to its parent.
5353

5454
.. code-block::
5555
@@ -63,11 +63,11 @@ Alternatively, using a list method such as :code:`append` dynamically *casts* th
6363
.. code-block::
6464
6565
>>> tree = easytree.dict()
66-
>>> tree.address
67-
<Node 'address'>
66+
>>> tree.address # undefined node
67+
<undefined 'address'>
6868
6969
>>> tree.address.country.append("United States")
70-
>>> tree.address
70+
>>> tree.address # now a dict
7171
{"country": ["United States"]}
7272
7373
@@ -85,7 +85,7 @@ Of course, you can use the dot or bracket notation interchangeably, both to read
8585
"bar"
8686
8787
.. note::
88-
The bracket notation remains necessary if the key is not a valid attribute identifier name.
88+
The bracket notation remains necessary if the key is not a valid attribute identifier name, or if the key is identical to a :code:`dict` method name.
8989

9090
.. code-block::
9191
@@ -119,15 +119,15 @@ Dictionaries assigned to an :code:`easytree.dict` or added to an :code:`easytree
119119
]
120120
121121
122-
Lists assigned to an :code:`easytree.dict` are *cast* as :code:`easytree.list` instances.
122+
Lists assigned to an :code:`easytree.dict` are also *cast* as :code:`easytree.list` instances.
123123

124124
.. code-block::
125125
126126
>>> tree = easytree.dict({"numbers": [1,3,5]})
127127
>>> isinstance(tree.numbers, easytree.list)
128128
True
129129
130-
Tuple values assigned to an :code:`easytree.dict` are also *cast*.
130+
Tuple values assigned to an :code:`easytree.dict` are also *cast* as tuples of :code:`easytree` objects.
131131

132132
.. code-block::
133133
@@ -206,15 +206,15 @@ Because the :code:`append` method returns a reference to the last appended item,
206206
207207
The undefined node
208208
------------------
209-
An :code:`undefined` node object created when an undefined attribute is read from an :code:`easytree.dict` node.
209+
An :code:`undefined` node object is returned when an undefined attribute is read from an :code:`easytree.dict` node. This falsy object contains a reference to its parent object, as well as the key from which this object was returned.
210210

211211
.. code-block::
212212
213213
>>> person = easytree.dict()
214214
>>> person.address
215-
<Node 'address'>
215+
<undefined 'address'>
216216
217-
Assigning or reading an attribute from an :code:`undefined` node *casts* it as a dictionary.
217+
Assigning or reading an attribute from an :code:`undefined` node *casts* it as a dictionary. This is possible since the :code:`undefined` object keeps a reference to its parent and the key from which it was returned.
218218

219219
.. code-block::
220220
@@ -249,7 +249,7 @@ By definition, and unless an easytree is sealed or frozen, reading an undefined
249249
250250
>>> profile = easytree.dict({"firstname":"David"})
251251
>>> profile.firstnam #typo
252-
<Node 'firstnam'>
252+
<undefined 'firstnam'>
253253
254254
Using a numeric key on an undefined node will cast the node as a dictionary, not a list.
255255

0 commit comments

Comments
 (0)