I am a newbie. I've seen tk.Frame.__init__(self, *args, **kwargs) this code here.
I am really confused. What exactly this would do?
Asked
Active
Viewed 27 times
-1
dead day
- 27
- 4
-
Which part? `tk.Frame` is the TKinter frame class. The `*args, **kwargs` is a common idiom for forwarding arguments in Python – Silvio Mayolo Feb 12 '22 at 05:29
-
'tk.Frame' What does it do? – dead day Feb 14 '22 at 15:57
1 Answers
1
This is fundamental part of python's standard way of creating subclasses. It doesn't really have anything specific to do with tkinter. However, if you subclass a tkinter class -- like with any class -- this will make sure that the base class is properly initialized.
What you're seeing, however, is an older style of initializing a base class. For python 3.x and beyond you should be using something like super().__init__(*args, **kwargs). See super and the description of Class objects in the standard python documentation.
Bryan Oakley
- 341,422
- 46
- 489
- 636