Best way to share a python list of objects
So I have a central list of python objects that I want to be able to share between different process that are possibly on different computers on the network. Some of the processes will add objects to list and another process will be a GUI that will view objects in the list. I want this all to happen in real-time (e.g once a processes adds an object to the list the GUI will see it.) What would be the best way to accomplish this. Some of my ideas: - An XML file r/w-able by all processes - Send pickled objects between all processes and each keeps it own list locally - A ascii type protocol akin to ftp the hands out all the info to the processes Any other ideas? What would work the best -- http://mail.python.org/mailman/listinfo/python-list
putting a string in Mac Address form
I came up with this. Is there a better (more pythonic) way to do it? import string def mac_to_norm(mac): def bad_char(char): if char not in string.hexdigits: return False return True mac = filter(bad_char,mac) if len(mac) is not 12: return None new_mac = '' c = 0 while len(new_mac) < 16: new_mac += mac[c:c+2] + ':' c=c+2 return new_mac[:-1].upper() print mac_to_norm('0012.ab23.b2cd') #shows: 00:12:AB:23:B2:CD The part I think is bad is the while loop part. Could it be better? -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie Question
solaris_1234 wrote: > I am trying to learn Python and I have a few questions. > > I have created a Class that is essentially a canvas with a red > background. After creation I want to change the background to green. > However I am having problems doing this. > > Here is my code: > > from Tkinter import * > > class MyApp: >def __init__(self, parent): > self.myParent = parent > self.myContainer = Frame(parent) > self.myContainer.pack() > > self.b1 = Canvas(self.myContainer, background="red").grid(row=0, > column=0) > > def ChangebgColor(self): >self(bg="green") > > > root = Tk() > myapp=MyApp(root) #Everything is fine at this point. > > raw_input() > > ChangebgColor(myapp.b1) # Error Message at this point > > raw_input() > > > > Any help will be greatly appreciated. here ya go. from Tkinter import * class MyApp: def __init__(self, parent): self.myParent = parent self.myContainer = Frame(parent) self.myContainer.pack() self.b1 = Canvas(self.myContainer, background="red") self.b1.grid(row=0,column=0) def ChangebgColor(self): self.b1.config(bg="green") root = Tk() myapp=MyApp(root) raw_input() myapp.ChangebgColor() raw_input() -- http://mail.python.org/mailman/listinfo/python-list
Re: Python riddle
SPE - Stani's Python Editor wrote: > I know that this code is nonsense, but why does this print 'Why?' > > a = 1 > if a >2: > try: > 5/0 > except: > raise > else: > print 'why?' last time i checked this should print 'why?' I have no idea how you got it to print 'Why?' -- http://mail.python.org/mailman/listinfo/python-list
network mapper Gui question
I am trying to make a program much like cheops that will make a graphical representation of my network. What would be the best language to make the actuall interface in, Tkinter, wxPython, PyGtk? And in those what module would work for something like this. It needs to be able to redraw it self about every half minute or so without being to heavy on the processor. Any ideas? -- http://mail.python.org/mailman/listinfo/python-list
dynamicly updating an objects fields
I want to make a function that will work like this: def updateField(object, fieldName, newValue): object.fieldName = newValue fieldName could be anything, the list of objects fields will grow as my project goes on and i want to reuse the same code without adding more if statements to it this is the only way I can see doing it right now: def updateField(object, fieldName, newValue): if fieldName = 'name': nodeDict[nodeID].name = newValue if fieldName = 'color': nodeDict[nodeID].color = newValue ..many more if's.. is the top example possible? -- http://mail.python.org/mailman/listinfo/python-list
Re: Hiding Console Output
Kkaa wrote: > I'm using the os.system command in a python script on Windows to run a > batch file like this: > > os.system('x.exe') > > The third-party program x.exe outputs some text to the console that I > want to prevent from being displayed. Is there a way to prevent the > output of x.exe from python? Use os.popen('x.exe') instead. -kyle -- http://mail.python.org/mailman/listinfo/python-list