Hi, i need to know What is self in Python
It’s a way for an object to refer to itself, and by extension, the elements contained within the object.
In the example below, the
self. prefix needs to be used with the
title() method as well as the
title_text variable in order to help Python distinguish between local variables or functions and any of the same names that may be global.
Let me know if this is enough of an explanation. I just got up and my brain may not be firing on all thrusters.
import tkinter as tk def main(): window = Window() window.mainloop() class Window(tk.Tk): title_text = "Hello, TkInter World!" def __init__(self): super().__init__() self.title(self.title_text) if __name__ == "__main__": main()