May-23-2023, 01:42 AM
I'm writing code to check various routers, part of it includes checking the traffic statistics, which is parsed per router. So I need either an open('file.txt')
or a with open context. I decided to stick with the context assuming it would be open until the entire program executed. The brlow for loop gets called by an outer function which is reccursed. Is this with context okay usage?
or a with open context. I decided to stick with the context assuming it would be open until the entire program executed. The brlow for loop gets called by an outer function which is reccursed. Is this with context okay usage?
for intf in interface_list: show_intf = "show interface {}".format(intf) result = ConnectHandler.send_command(show_intf) rate = re.search(input_rate, result) bandwidth = re.search(bw_template, result) if int(rate.group("rate")) / int(bandwidth.group("bandwidth")) >= 0: with open() updated_interfaces.append(intf)or should I stick with traditional open, close