I’m trying to get the def wfsc_pod1 and wfsc_ip into the same def. I’m not quite sure how to approach the problem. I want wfsc_pod1 to display all the information for name, subnet and gateway. Then wfsc_ip shows the ip addresses below it. I also get a None value when I run it as it. Not sure why. Anything more pythonic is more appreciated.
class OutageAddress:
subnet = ["255.255.255.0", "255.255.255.1"]
# Gateway order is matched with names
gateway = ["192.168.1.1", "192.168.1.2", "192.168.1.3", "192.168.1.4",
"192.168.1.5", "192.168.1.6", "192.168.1.7", "192.168.1.8",
"192.168.1.9"]
name = ["LOC1", "LOC2", "LOC3", "LOC4",
"LOC5", "LOC6", "LOC7", "LOC8",
"LOC9"]
def wfsc_pod1(self):
wfsc_1 = "%s\t %s\t %s\t" % (network.name[0],network.subnet[0],network.gateway[0])
return wfsc_1
def wfsc_ip(self):
for ip in range(100,110):
ip = "192.168.1."+str(ip)
print ip
network = OutageAddress()
print network.wfsc_pod1()
print network.wfsc_ip()
First of all, you probably meant to write
wfsc_pod1like this:and call
wfsc_iplike this:If you want to combine
wfsc_pod1andwfsc_ip, you can do this:and call this function with a print statement.
However, a better approach (IMO) would be to add print statements inside
wfsc_combinedand call it without a print statement: