Dave Cinege Git Repo thesaurus / eaeaa7c
README.rst edit Dave Cinege 2 years ago
1 changed file(s) with 12 addition(s) and 71 deletion(s). Raw diff Collapse all Expand all
1111 t = thes()
1212 t.set_path('a.b.c.d', 'Hello')
1313 print(t['a']['b']['c']['d']) # as nested items
14 print(t.a.b.c.d) # as attributes
14 print(t.a.b.c.d) # attribute aliasing
1515 print(t.a.b['c'].d) # as both
1616 kp = Keypath('a.b.c.d')
1717 print(t[kp]) # as a keypath
138138 I want to be comfortable this feels natural to others or make changes.
139139
140140
141 Copyright and License Information
142 ---------------------------------
143
144 Copyright (c) 2012 - 2019 Dave Cinege. All rights reserved.
145
146 See the file "LICENSE" for information on the history of this software,
147 terms & conditions for usage, and a DISCLAIMER OF ALL WARRANTIES.
148
149
150
151
152
153 BELOW IS OLD/IN PROGRESS - NOT COHERENT
154
155 ####################################################
156
157
158 What is attribute alaising?
159 Attribute alaising refering to redirecting the methods __getattr__()
160 and__setattr__() to __getitem__() and __setitem__() respectivly.
161
162 The effect is to syntatically reference keys like attributes.
163
164 For example:
165 .. code::python
166 t['k']
167 t.k
168
169 are treated the same.
170
171 Thesaurus also provides a special alias
172
173
174 What is key recursion?
175
176
177 G.gws.lv._1.gw
178
179
180 For example:
181 .. code:: python
182 t = thes()
183 t.set_path('k._k.__k.___k', ','Hello')
184 t['k']['_k']['__k']['___k']
185 t.k._k.__k.___k
186
187 Becasue of the nature pof Thesaurus, keys shodul be of trype str()
188
189
190 , difference being the latter will recurse or
191 'walk the key directory tree' until
192
193
194 What is a keypath?
195 A keypath is a
196 It may be represented by a string with path elements seperated by dots.
197 t['k']
198
199
200
201 Thesaurus
202
203 Nested dictionarys which I refer to as dictionary trees (aka nested dictionaries.)
204
205 DICTIONARY DIRECTORYS
206
207 from thesaurus import thes
208 from thesaurus import thesext as thes
209
210 # OLD README
141 First Release Description from 2012
142 ------------------------------
211143 Thesaurus is a pure dictionary subclass which allows calling keys as
212144 if they are class attributes and will search through nested objects
213145 recursively when __getitem__ is called.
222154 a dictionary that could act (sort of) like a class, Thesaurus may be for you.
223155
224156
157 Copyright and License Information
158 ---------------------------------
225159
160 Copyright (c) 2012 - 2019 Dave Cinege. All rights reserved.
161
162 See the file "LICENSE" for information on the history of this software,
163 terms & conditions for usage, and a DISCLAIMER OF ALL WARRANTIES.
164
165
166