|
Dear tutors:
       I have some questions about memory mechanism of python. Do the elements 
of the parent go into the namespace of the subclass when we define subclass?
 
As far as I'm concerned, they do go into the namespace of the subclass. Because 
when we use dir(), we can see all the elements. But there is only one 'update' 
name. I think the function of the subclass override the parent's.  In this 
situation , when we instantiate the subclass, we just need one argument, that 
is to say, the parent's update function do the work. It confuses me. 
According to my understanding, as there is no 'super' key word, the 'self' 
should inference to the instance of the subclass when we initiate the subclass. 
So self.__update should inference to function of the subclass.
Another quesion is about the meaning of the private variables. What condition 
shall we use them? In other word, I wanna know the purpose of introducing the 
private variables. The above-mentioned example, I think, is not enough to 
explain it, because when we change the __update to update, there is no change 
except for using update rather than _Mapping__update to inference it.
The last question is about the storage of the data. For a given data, like 1 or 
'1', what's the form when python saves it in the memory? To be more specific, I 
wanna know the number of the parts we use to enclose it. For example, python 
uses 3 parts to save it. One is for the value. The second for the type of the 
data, ie, inter,str,etc. The last is for the pointer or id to show the place  
where it is stored.
Hope to hear from you soon. Have a good weekend!
Yours, sincerely.


Phoenix










|
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to