Dave Cinege Git Repo thesaurus / 4faa677
README.rst edit Dave Cinege 2 years ago
2 changed file(s) with 34 addition(s) and 27 deletion(s). Raw diff Collapse all Expand all
22 clean:
33 -rm *.pyc *.pyo
44 -rm -R __pycache__
5 html:
6 -rst2html5 README.rst README.html
00 Python Thesaurus and ThesaurusCfg
11 =========================================
2
3 Python Thesaurus - "A different way to call a dictionary."
4
25 Copyright (c) 2012-2019 Dave Cinege. All rights reserved.
36
47 See the end of this file for further copyright and license information
58
6 General Information
7 -------------------
8
9 :Source code: https://git.cinege.com//thesaurus
9 :Source code: https://git.cinege.com/thesaurus
1010 :Telegram Group: https://t.me/PythonThesaurus
11
12 At the moment there is no email list, wiki, etc.
1311
1412
15 Quick start
16 ------------
17 ::
13 Quick Start
14 -----------
15
16 .. code:: bash
1817
1918 $ python thesauruscfg_sample.py
2019
2322 are all about.
2423
2524
26 Quick look
27 ----------
28 ::
25 Quick Overview
26 --------------
27
28 .. code:: python
2929
3030 from thesaurus import thes, Keypath
3131 t = thes()
3232 t.set_path('a.b.c.d', 'Hello')
33 print(t['a']['b']['c']['d']) # as nested items
33 print(t['a']['b']['c']['d']) # as nested keys
3434 print(t.a.b.c.d) # attribute aliasing
3535 print(t.a.b['c'].d) # as both
36 kp = Keypath('a.b.c.d')
37 print(t[kp]) # as a keypath
3836
39 >>> 'a.b.c.d' in t
37 kp = Keypath('a.b.c.d') # a keypath obj
38 print(t[kp]) # keypath as the 'key'
39 print('The value: {a.b.c.d}'.format(**t))
40 print(f'The value: {t.a.b.c.d}') # py3.6+ f-string. perfection!
41
42 >>> 'a.b.c.d' in t # recursive contains
4043 True
41 >>> kp[:-2] in t
44 >>> kp[:-2] in t # keypath slicing! (== 'a.b' in t)
4245 True
43 >>> print(kp)
46 >>> print(kp) # keypath's str() dotted
4447 'a.b.c.d'
4548 >>> print(repr(kp))
46 ['a', 'b', 'c', 'd']
49 ['a', 'b', 'c', 'd'] # but it's really like a list
4750
4851
4952 cfgs = '''
8588 so are you.
8689
8790 ThesaurusExtended is a subclass of Thesaurus providing additional
88 usablity methods.
91 usability methods such as recursive key and value searching.
8992
9093 ThesaurusCfg is a subclass of ThesaurusExtended providing a configuration
9194 file parser and per key data coercion methods.
130133 - Decide how to properly handle copying ThesaurusCfg coercion methods.
131134
132135 - Resolve Thesaurus's schizophrenia.
133 ::
134
135 v = t['a.b.c'] # This recurses
136 t['a.b.c'] = v # This does not, needs set_path().
137
138 I want to be comfortable this feels natural to others or make changes.
136
137 .. code:: python
138
139 v = t['a.b.c'] # This recurses
140 t['a.b.c'] = v # This does not, needs set_path().
141
142 I want to be comfortable this feels natural to others or find a
143 better way.
139144
140145
141 First Release Description from 2012
146 Early Release Description from 2013
142147 -----------------------------------
143148 Thesaurus is a pure dictionary subclass which allows calling keys as
144149 if they are class attributes and will search through nested objects