i think as i continue this book this thing will become clear
yes i am bit focusing on theory and terms because without knowing what is happening behind the scene does not giving me confidence to practice EX41 and to move on with book
i think what was main obstacle is confusion between instance and object which is now clear
can you do me a one last favor
read this post in which i asked question about calling a class by two different ways
I know you want to get all the theory language down, but honest, go play with the code so you can see it in actionâŚ
The first version is assigning that class, my blueprint to âfooâ. It is not an instance â active usable copy of the class.
The second version is the instance being assigned to âfooâ.
Make a simple class with simple attributes.
Try to get those values of those attributes and print them.
Try to assign new values to those attributes of that simple class.
Look at your resultsâŚ
Then:
Make an instance of that simple classs
repeat steps 1 - 3.
there are classâs in the python language we use all the time without knowing it.
what would happen if someone could accidently or purposely change the class code?
This is a big reason the only way to use a class is to have an active copy of it, and NOT the class (and itâs original code) itself.
oh so
in first version init does not run so instance is not created and zed said that self is a variable for the instance/object being accessed so there is no instance/object so self is not going to refer anything so thatâs why we canât access K
in second version instance is created and assigned to foo so self can refer to object foo so we can access K