More Than One Way to Skin a Snake

 The same above title (skin the cat-snake) still applies here, but as a post script edit to this post, I'm going to give it an entirely different spin than originally planned. Here it goes:

My current Py project has evolved into needing a customized data structure. Never mind its specifics.  (Maybe I'll come back to those later.)

As I started formulating the ideas / concepts for the customized data structure, I recalled having vaguely seen mention of a thing in Python called "DataClasses". Had no idea what it actually was. It intrigued me. So I started chasing after it (started searching for clues).

Turned out to be a popular topic. Many, many tutorials about it.

So should I pick just one lecturer? (e.g. Tech with Tim/other (TwT, TwX), Indently, Bro Code, Mosh, Nana, ... or any of the other many free Py tutors) and stick with that one explainer?

No. It so happened that jumping around allowed me to pick up different nuances about the stuff they were talking about, some of which was first time for me. More specifically, the automatically filled dunder functions of __init__, __repr__ and __eq__ 


One lecturer in particular provided the metaphor (or analogy) of the __init__ Dunder method being like a construction company that constructs/ builds a class of buildings based on provided specifications. This constructor process is separate from the process associated with the use of a particular instance of the built building --say one located at a given map point (house address) that is in a residential zone or a commercial zone. The specs for constructing and the spec for using may be somewhat independent from one another.
 

Still, as I tried to implement some of the DataClass stuff being spoken of by the lecturers, I found that I was not able to truly wrap my head around the fundamentals of this DataClass stuff/

Part of the problem is that I had not yet studied what a "Decorator" is. DataClass operates as a Decorator! Yikes

Another problem is that the language used by the lecturers to explain what DataClass does, did not connect to any metaphorical constructs already present in my brain. So it didn't attach. It didn't stick. (see neuroscience here)

My current take on it is this: A "class" is a template for instantiating a not-yet-instantiated "object". To instantiate the object, you must "construct" it --otherwise known as building it or "initiating" it with the __init__ function that must be included inside of each class declaration. The DataClass decorator (@dataclass) automatically generates a hidden __init__ (self, other params) function based on the type hints you declare inside your decorated class template. 

See Geeks-4-Geeks example to the right (link is here)
work-in-progress


The older cat skin was about this:

The unicodes include various escape codes such as /n, /t, /r and so on

One of the listed escapes says it moves the cursor print point on you console up n number of lines

Problem is, when I tried using that escape, it didn't work.

What now?
Give up?

TO BE CONTINUED ....


MORE TO EXPLORE
>> ArjanCodes == includes @dataclass plus more == (25) Python Has the Best Standard Library Ever: 10 Modules You Need to Know - YouTube

Google search = "the learn how to learn page for old man learning to code in python"
                            --^^^-- see what the AI preview suggests

    ---^^^--- 10 Nooby Python Mistakes Beginners Make — Fix Them Fast (Code Examples)
    ---^^^--- FREE Python Course for Beginners (13 HOURS)





Comments

Popular posts from this blog

Links for Python Noobs

The Learn HOW to Learn Page

Welcome to Circular Import Hell