iterating over a list and printing
Richie Hindle
richie at entrian.com
Wed Feb 11 10:41:22 EST 2004
[Bart]
>>> ip_list.append(inputFile.read())
You probably meant something like this (untested):
inputFile = file('ips.txt', 'r')
ip_list = inputFile.readlines() # Note readlines() rather than read()
inputFile.close()
for i in ip_list:
print "/sbin/ifconfig %s netmask 255.255.252.0 broadcast 128.173.123.255 up" %i
If you really do need to create ip_list up front and append to it,
you should use extend() rather than append() - see the "mutable
sequence types" documentation for details.
--
Richie Hindle
richie at entrian.com
More information about the Python-list
mailing list