A Time Out From Real Coding
It feels as if it was longer, but apparently I needed some time out from actual coding for diversion, reflection and introspection. (More here) and (here)
[Jump to latest thoughts-- click here]
I found every excuse for not doing OOP project #2 which is the abbreviation expansion class and its "objects".
Was it nothing more than falling into a bunch of easy-dopamine traps? Did I get stuck in the identity-politics debates? Did I let 'notifications' on my smart phone distract me? Perhaps. Or maybe I needed to rewire my mental models in the background (the subconscious) of how OOP objects should be viewed?
So now I have a new view of what the definitions should be for what is a "class"? For what is an "object", "attributes", "methods", the init method and so on; all to be found (HERE = an earlier OML2code post)
Given that, I've also re-designed the plan for my expander cookie-cutter (aka 'class') per the following:
class AbvXpandr:
# This is my SECOND OOP attempt. Below is position of params when a Abbreviations Expander object/widget is instantiated
# p1= in_txt = input text includes abbreviation initiators /triggers
# p2= out_txt = to-be -generated expanded text (Abbreviations are Expanded]
# p3= abvi = single character abbreviation initiator (e.g. the tilted quote under the Tilda key)
# the p3 is followed by a single char other than p3 or p4, the single is expanded via p5 Dictionary
# p4= abvjj = start/end delimiter between which we have N>0 chars as abv code (e..g the Tilda "~")
# Special case 01: seq of p3p3 chars (no space) is a special, most often used abbreviation (eg white forefront text on black background escape strings)
# Special case 02: seq of p4p4 (no space) is a special, 2nd most often used abbreviation (eg yellow forefront on black background)
# Special case 03: seq of p3p4 (no space between) is a special (e.g. white on blue),
# Special case 04: seq of p4p3 (no space between) is a special (e.g. blue on yellow),
# Special case 05: seq of p3p3p3 (no spaces between) is a special, --perhaps? This allowing for longer permutations of p3/p4 with no spaces between for most often used abbreviations that are easy to type in
# p5= abvD = the abbreviations lookup Dictionary for p3 { "a": 'allowance ', "b": 'because ' ... "z": 'zero '}
# p6= abvDD = the abbreviations lookup Dictionary for a p4 pair { "ab": 'about ', "qab": 'Query About ' ... "z": '??? '}
# p7= abvDDS = the abbreviations lookup Dictionary for special p3/p4 cases { p3p3: white, p4p4: yellow, ... "p3p4": '? '}
# p8= module_name = where to extract abvD, abvDD and abvDDS dictionaries from
# p9= default_max =50 #default max_count if loop max_count is excessive
def __init__(self, in_txt, out_txt, abvi, abvjj, abvD, abvDD, module_name, default_max):
self.xxx = xxx
(2) scan input text for syntax violations and special case sequences, save indices for these
(3) scan input text for non-special expander codes (e.g. [p3][c1] or [p4][c2][c3][c4][p4]
where c1, c2, ... cN are the abbreviation codes that are to be expanded), save indices
(4) apply found keys to appropriate dictionaries
(5) append to growing output text
It just forms the basic idea for the data structures to be generated for analyzing the input:
Confusions and Answers to those Confusions:
(1) gQAB ::: In a python class def, after assigning self.parameter in init, should I refer to the parameter alone or with the dot notation?
(2) gQAB ::: In a python, which string methods should I use to detect a char and determine its index?
(2b) Using index() : The index() method returns the index of the first occurrence of a character. If not found, it raises a ValueError.
(2c) Using a Loop : with range() and len()
(2d) Using find() : find() method returns the index of the first match. If not found, it returns -1.
[ related G4G articles: enumerate(), next(), reverese find= findr(), re.search() ]
MORE TO EXPLORE
--^^^-- Python Basics Course with AI Support
--^^^--
--^^^--
--^^^--
--^^^--
--^^^--
--^^^--
--^^^--
--^^^--
--^^^--
--^^^--
--^^^--
--^^^--
--^^^--
--^^^--
--^^^--
--^^^--
--^^^--
--^^^--
--^^^--
--^^^--
--^^^--
--^^^--
--^^^--

Comments
Post a Comment