我是Python的新手。我在我所工作的OpenFlow控制器中遇到了Python代码。
class SimpleSwitch(app_manager.RyuApp):
OFP_VERSIONS = [ofproto_v1_0.OFP_VERSION]
def __init__(self, *args, **kwargs):
super(SimpleSwitch, self).__init__(*args, **kwargs)
self.mac_to_port = {}
我的问题如下。
__init__
是类的构造函数吗?self
和 C++ 中的this
指针一样吗?super(SimpleSwitch, self).__init__(*args, **kwargs)
是调用父类/超类的构造函数吗?你可以将
mac_to_port
添加为self
的新成员吗?还是已经添加并在此进行初始化了?