Nested __init__ statements what do they do?

In addition to what others have said, there's probably some more advanced meta-programming at play that I'm not familiar with. Frameworks sometimes use seemingly empty classes and functions that get populated at runtime, so things will be there that aren't immediately obvious. I'd bet that there are some other shenanigans going on between Widget and Frame that give more meaning than what's apparently there just by the trace.


Ninja edit:

It looks like that's not actually what's going on here. Do look out for that if you use other frameworks, but no - this is the special code that needs to get run.

class Frame(Widget):
    def __init__(self, master=None, cnf={}, **kw):
        """Construct a frame widget with the parent MASTER.

        Valid resource names: background, bd, bg, borderwidth, class,
        colormap, container, cursor, height, highlightbackground,
        highlightcolor, highlightthickness, relief, takefocus, visual, width."""
        cnf = _cnfmerge((cnf, kw))
        extra = ()
        if 'class_' in cnf:
            extra = ('-class', cnf['class_'])
            del cnf['class_']
        elif 'class' in cnf:
            extra = ('-class', cnf['class'])
            del cnf['class']
        Widget.__init__(self, master, 'frame', cnf, {}, extra)

github source

/r/learnpython Thread Parent