Python Instance Variables

preview_player
Показать описание
Looks at instance variables of a Python object and in the process discusses the scope of an instance variable. It also considers the use of the self parameter and its role in setting up instance variables.
Рекомендации по теме
Комментарии
Автор

John Philips Jones, You are a great teacher

Codality
Автор

Wonderful...simple and clear, with just enough repetition to help it sink in.
thanks again.

quazichimp
Автор

Your videos are really great. Thanks for doing these.

mcvideo
Автор

If we can use other words instead "self" as a parameter, then why a parameter in one of previous videos where value was sent as only parameter was recognized as TypeError. (I really appreciate and grateful for your videos and explanations. I have learnt a lot especially with tkinter framework from your videos)

eldarmammadov
Автор

>>> c = int(8)
>>> print(c)
8


In the above example which is an instance of int class we are able to print the value assigned to 'a' without using any method. However, in the below example based on this vidoe print option does not display the value directly and we have to use method to access the value.


What I have understand is that not all the class built restrict the access to data using method.



>>> class a:
def __init__(self, value):
self.value = value
self.double = self.value*2
def getvalue(self):
return self.value
def getdoubled(self):
return self.double


>>> b = a(9)
>>> print(b)
<__main__.a object at


>>> print(b.getvalue())
9

nasrullahturke
Автор

John, in your final words in each video you speak about joining a "circle" that relates to the videos. Unfortunately I could not quite understand what circle you are talking about. English is not my native tongue as I am from the continent ( The Netherlands :)

Lennardish
Автор

Thank you very much for the time you invest in transferring knowledge.. I have a brief question ? Given that you've made a class here CurrentAccount and the instance too, why it's impossible with print (dir. (account_holder)) to access instanc method it already shows an error in the program. You hope you understand my question. Thanks in advance

armingal
Автор

Hello, I enjoy your videos very much. My question when a instance object is created in the execution space, why does each object have the methods(code)? Why not just a pointer to the code? The code for all instances of the class is the same, only the attributes are different. Am I wrong?

leanneglenn
Автор

But what is the difference with making an object and an instance

andrejoseph
welcome to shbcf.ru