How can I improve this code:
import random
def rand_mac():
return "00:00:00:%02x:%02x:%02x" % (
random.randint(0, 255),
random.randint(0, 255),
random.randint(0, 255)
)
add_acl_mac = rand_mac()
add_acl = 'mac access-list extended name test deny src {}-{} dst any\r\n'.format(add_acl_mac, add_acl_mac)
acl_list = 1
while (acl_list <=1024):
network.sendline(add_acl)
acl_list += 1
Current behavior: the loop writes the same MAC 1023 times.
Proposed behavior: the loop will write at each iteration a different MAC, for 1023 times.
I've been reading about generators and yield but I fail to understand how to properly use them in my current situation, if indeed they are to be used.
Thanks!