Newbie: need help with control loop

Shaggy nospam.python at scoobysnacks.com
Sun Dec 12 19:33:22 EST 1999


I'm trying to write a simple program to change passwords on a large
number of routers but I'm having trouble with the control loop.  This
may be very poor code but I've only been at this for a week.  I want
to do more than one router at a time so I don't have to wait for each
one to finish before I start the next.  I also don't want to start ALL
of them at the same time.  The problem I'm having is being able to
create an object instance based on a list value.  The list is
arbitrary and may change often.  Here is where I'm at.

if __name__ == '__main__':
	list=['host1','host2','host3','host4','host5',
		'host6','host7','host8','host9','host0']
	running=[]
	for machine in range(len(list)):
		running = running + [list[machine]]

		"""I want right here to create a class instance
			based on list[machine] and have it begin

	??	list[machine]=testclass()  ??      """

		while len(running) >= 4 : # no more than 4 working

			for currentitem in range(len(running)):
				#
				# kill if done
				# if instance.status == ('done') :
					#del instance
				print running[currentitem],

			del running[0]
			print ''
	#loop to finish anything remaining in running[]

Any and all help appreciated.



More information about the Python-list mailing list