Hitesh Joshi a écrit : (snip) > But if I try to create a for loop like this it doesn't work.... how can > I pass computerName var as an argument? > What am I doing wrong here? Thank you in advance.... > > import os > > Computerlist = ['PC1', 'PC2', 'PC3', 'PC4', 'PC5'] > for ComputerName in Computerlist: > print ComputerName > os.system('net send ComputerName "Message"') > What you pass to os.system is the litteral string 'net send ComputerName "Message"'. This string is passed 'as is' - the fact that it contains 'ComputerName' won't invoke any magic...
Try this instead: Computerlist = ['PC1', 'PC2', 'PC3', 'PC4', 'PC5'] for ComputerName in Computerlist: os.system('net send %s "Message"' % ComputerName) <ot> In Python, CapitalizedNames are usually used for class names. You'd better use all_lowers_with_underscores, or at least mixedCase. </ot> -- http://mail.python.org/mailman/listinfo/python-list