iterating over a list and printing
bart_nessux at hotmail.com
Wed Feb 11 17:12:25 CET 2004
Richie Hindle wrote:
> You probably meant something like this (untested):
> inputFile = file('ips.txt', 'r')
> ip_list = inputFile.readlines() # Note readlines() rather than read()
> for i in ip_list:
> print "/sbin/ifconfig %s netmask 255.255.252.0 broadcast 22.214.171.124 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.
Thanks to everyone for the replies. This works now.
More information about the Python-list