The execution order of functions judged by for Loop and if under python

if the question starts on line 4 of the program, the for loop is followed by if judgment, and then name=self._nic_ovs_name_pattern.search (o) refers to the if conditional judgment returns true before the assignment operation is performed? Or is it executed when if returns False? When the return ovs_nics, of the last line is met, what conditions are returned? The overall execution order of this function is not very clear, please give me some advice, thank you.

def __extract_ovs_nic_detail(self, output):
    ovs_nics = []
    ovs_nic = {}
    for o in output.split("\n"):
        if "_uuid               : " in o:
            ovs_nic = {}
        name = self._nic_ovs_name_pattern.search(o) 
        if not name is None:
            ovs_nic["name"] = name.group(2).strip("\"")
        mac = self._nic_ovs_mac_pattern.search(o) 
        if not mac is None:
            ovs_nic["mac"] = mac.group(2).strip("\"")
        mtu = self._nic_ovs_mtu_pattern.search(o) 
        if not mtu is None:
            ovs_nic["mtu"] = mtu.group(2)
        speed = self._nic_ovs_speed_pattern.search(o)
        if not speed is None:
            ovs_nic["speed"] = str(int(speed.group(2)) / 1000000) + "Mb/s"
        if "type                : " in o:
            ovs_nics.append(ovs_nic)
    return ovs_nics
Mar.23,2021

in terms of the code you give:

as long as you enter the for loop name=self._nic_ovs_name_pattern.search (o) , it will be executed, and it has nothing to do with if'_ uuid:'in o: to judge whether it is true or not.

in any case, the return ovs_nics statement returns

< hr >

if you want to read python code, or even write python programs, I suggest you learn python syntax, after all, you can usually learn it very quickly. It is recommended that you read the Concise Python tutorial

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1c25e6e-337bc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1c25e6e-337bc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?