I'm fairly rusty in Python (and my skills, when not rusty, are rudimentary at best), and I'm trying to automate the creation of config files. I'm basically trying to take a list of MAC Addresses (which are manually inputted by the user), and create text files with those MAC Addresses as their names, with .cfg appended to the end. I've managed to stumble around and accept the user input and append it into an array, but I've ran into a stumbling block. I'm obviously in the very infant phase of this program, but it's a start. Here's what I've got so far:
def main():
print('Welcome to the Config Tool!')
macTable = []
numOfMACs = int(input('How many MAC addresses are we provisioning today? '))
while len(macTable) < numOfMACs:
mac = input("Enter the MAC of the phone: "+".cfg")
macTable.append(mac)
open(macTable, 'w')
main()
As can be seen, I'm trying to take the array and use it in the open command as the filename, and Python doesn't like it.
Any help would be greatly appreciated!
open(macTable, 'r')becauseopenexpects a string for the first argument, not a list. You canfor fname in macTable: open(fname, 'w'), though.