Bruno Desthuilliers wrote: > gel wrote: > > gel wrote: > > > > > >>Hi > >>I would like to pass a variable in and use it as part of a name of an > >>object, something like below, where I pass the variable software into > >>the function and use it as part of the name of the object so that I can > >>append to it using the other vairables. Any suggestions? > >> > >> > >> def a_d(self,software,mac,time,extra):
> >> global d_software > >> d_software.software.append([mac,time,extra]) > > > > > > I sorted it out > > > Then do a favour to other persons facing the same problem : share your > solution. As a side effect, you'll also have your code checked by lot of > confirmed Python programmer !-) > > -- > bruno desthuilliers > python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for > p in '[EMAIL PROTECTED]'.split('@')])" OK, I would love to, the reason I did not was for fear of wasting peoples time with basic stuff... I ended up doing it a bit differently what I am doing is using pyro to make a package that can be run on PCs to control how many PC on a network are running a piece of software,the function def a_d(self,software,mac): global d_software d_software[software][0].append(mac) return d_software is in the module on the pyro server. When this object is used on the client it adds the clients mac address to the dictionary list. When another client is runs the software being watched it checks how many are already running by counting the number of mac addresses already in there. If the number of PCs already running the software is below the number allowed, which is set in the pyro module it is allowed to continue to run it. If the limit has been reached the client software kills the software, Below is the client and the pyro module... Client import wmi import time import Pyro.core c = wmi.WMI() o=Pyro.core.getAttrProxyForURI('PYRONAME://:Default.test') for interface in c.Win32_NetworkAdapterConfiguration (IPEnabled=1): # print interface.Description, interface.MACAddress for ip_address in interface.IPAddress: mac = interface.MACAddress mac = 1 current_time = time.time() sw = "notepad.exe" #o.a_d(sw, mac, current_time, "Maybe More Extra Stuff too") while 1: time.sleep(1.0) ps_li=[] for process in c.Win32_Process (): # print process.ProcessId, process.Name ps_li += [process.Name] if sw in ps_li: if len(o.r_d()[sw][0]) != 0: if mac in o.r_d()[sw][0]: print "Already in there" else: #ps_id = ps_li.index(sw) if len(o.r_d()[sw][0]) < o.r_l()[sw]: o.a_d(sw, mac) print "There are some" print o.r_d() else: print "There are none" for process in c.Win32_Process (): if process.Name == "notepad.exe": print process.ProcessId, process.Name result = process.Terminate () print process.Name +" has been killed" else: o.a_d(sw, mac) print "First in" else: print sw + " not running" pyro module class testclass: import wmi import time global d_software global l_notepad global d_licence_numbers d_licence_numbers = {"notepad.exe":1, "Adobe":1} l_notepad =[] d_software = {"notepad.exe":[[],[]], "Adobe":[[],[]]} def r_len_d(self): return len(d_licence_numbers) def a_d(self,software,mac): global d_software d_software[software][0].append(mac) return d_software def r_d(self): return d_software def r_l(self): return d_licence_numbers -- http://mail.python.org/mailman/listinfo/python-list