COM and Threads
I have an application which uses COM 's Dispatch to create a COM based object. Now I need to upgrade the application to a threaded one. But its giving an error that COM and threads wont go together. Specifically its an attribute error at the point where COM object is invoked. Any pointers please?? -- http://mail.python.org/mailman/listinfo/python-list
Re: COM and Threads
hg wrote: > Teja wrote: > > I have an application which uses COM 's Dispatch to create a COM based > > object. Now I need to upgrade the application to a threaded one. But > > its giving an error that COM and threads wont go together. Specifically > > its an attribute error at the point where COM object is invoked. Any > > pointers please?? > > > > If COM is not thread safe, then use processes Thanks a LOT for your reply.. Can u please tell me how to processes.. -- http://mail.python.org/mailman/listinfo/python-list
Re: COM and Threads
Roger Upole wrote: > "Teja" <[EMAIL PROTECTED]> wrote: > >I have an application which uses COM 's Dispatch to create a COM based > > object. Now I need to upgrade the application to a threaded one. But > > its giving an error that COM and threads wont go together. Specifically > > its an attribute error at the point where COM object is invoked. Any > > pointers please?? > > > > An actual traceback would help. > At a guess, when using COM in a thread > you need to call pythoncom.CoInitialize and > CoUninitialize yourself. > > Roger Actually Roger, this is the scenario I create a COM object at the beginnning of the main thread. In the sub thread, I need to access the same instance of the COM object. If it were a normal object ie. not a COM obj, i was able to do it. But if it were a COM object, its giving an attribute error? Should I pass a COM object to the thread. If so How? Please let me know ASAP... Thnks -- http://mail.python.org/mailman/listinfo/python-list
Re: COM and Threads
hg wrote: > Teja wrote: > > hg wrote: > > > >> Teja wrote: > >>> I have an application which uses COM 's Dispatch to create a COM based > >>> object. Now I need to upgrade the application to a threaded one. But > >>> its giving an error that COM and threads wont go together. Specifically > >>> its an attribute error at the point where COM object is invoked. Any > >>> pointers please?? > >>> > >> If COM is not thread safe, then use processes > > > > Thanks a LOT for your reply.. Can u please tell me how to > > processes.. > > > > I gather pywin32 gives you the trick to do it (CreateProcess ?) as I > gather "fork"ing is not available under Windows. Hg, This is the scenario.. I create a COM object in main. I need to access that object in a thread or subprocess or whatever. Can u pls tell me how to do it. Its a COM object. Thnks -- http://mail.python.org/mailman/listinfo/python-list
Re: COM and Threads
Roger Upole wrote: > "Teja" <[EMAIL PROTECTED]> wrote: > > > > Roger Upole wrote: > > > >> "Teja" <[EMAIL PROTECTED]> wrote: > >> >I have an application which uses COM 's Dispatch to create a COM based > >> > object. Now I need to upgrade the application to a threaded one. But > >> > its giving an error that COM and threads wont go together. Specifically > >> > its an attribute error at the point where COM object is invoked. Any > >> > pointers please?? > >> > > >> > >> An actual traceback would help. > >> At a guess, when using COM in a thread > >> you need to call pythoncom.CoInitialize and > >> CoUninitialize yourself. > >> > >> Roger > > > > Actually Roger, this is the scenario > > > > I create a COM object at the beginnning of the main thread. In the sub > > thread, I need to access the same instance of the COM object. If it > > were a normal object ie. not a COM obj, i was able to do it. But if it > > were a COM object, its giving an attribute error? Should I pass a COM > > object to the thread. If so How? Please let me know ASAP... Thnks > > > > To pass COM objects between threads, usually they'll need to be marshaled > using pythoncom.CoMarshalInterThreadInterfaceInStream, and unmarshaled > with pythoncom.CoGetInterfaceAndReleaseStream. > > Roger I really appreciate your quick replyCan u please let me know how to do marshalling and unmarshalling or any good refrences to do it. Because i tried to do it. I got some errors ans so I left it... Thnks again... -- http://mail.python.org/mailman/listinfo/python-list
Re: COM and Threads
Roger Upole wrote: > "Teja" <[EMAIL PROTECTED]> wrote: > > > > Roger Upole wrote: > > > >> "Teja" <[EMAIL PROTECTED]> wrote: > >> > > >> > Roger Upole wrote: > >> > > >> >> "Teja" <[EMAIL PROTECTED]> wrote: > >> >> >I have an application which uses COM 's Dispatch to create a COM based > >> >> > object. Now I need to upgrade the application to a threaded one. But > >> >> > its giving an error that COM and threads wont go together. > >> >> > Specifically > >> >> > its an attribute error at the point where COM object is invoked. Any > >> >> > pointers please?? > >> >> > > >> >> > >> >> An actual traceback would help. > >> >> At a guess, when using COM in a thread > >> >> you need to call pythoncom.CoInitialize and > >> >> CoUninitialize yourself. > >> >> > >> >> Roger > >> > > >> > Actually Roger, this is the scenario > >> > > >> > I create a COM object at the beginnning of the main thread. In the sub > >> > thread, I need to access the same instance of the COM object. If it > >> > were a normal object ie. not a COM obj, i was able to do it. But if it > >> > were a COM object, its giving an attribute error? Should I pass a COM > >> > object to the thread. If so How? Please let me know ASAP... Thnks > >> > > >> > >> To pass COM objects between threads, usually they'll need to be marshaled > >> using pythoncom.CoMarshalInterThreadInterfaceInStream, and unmarshaled > >> with pythoncom.CoGetInterfaceAndReleaseStream. > >> > >> Roger > > > > I really appreciate your quick replyCan u please let me know how to > > do marshalling and unmarshalling or any good refrences to do it. > > Because i tried to do it. I got some errors ans so I left it... > > > > Thnks again... > > > > Here's a simple example using Internet Explorer. > > import win32com.client, pythoncom, thread > ie=win32com.client.Dispatch('internetexplorer.application') > ie.Visible=1 > > def nav(istream, dest): > pythoncom.CoInitialize() > d=pythoncom.CoGetInterfaceAndReleaseStream(istream, > pythoncom.IID_IDispatch) > my_ie=win32com.client.Dispatch(d) > my_ie.Navigate(dest) > pythoncom.CoUninitialize() > > s=pythoncom.CoMarshalInterThreadInterfaceInStream(pythoncom.IID_IDispatch,ie) > thread.start_new_thread(nav, (s, 'www.google.com')) > > Roger Thnks a lot Roger, Its working gr8..Now, once the thread is started with start_new_thread, is there any way to terminate it upon user's request. I have explored and found out that there is no thread.kill(). So wht to do now? Teja -- http://mail.python.org/mailman/listinfo/python-list
Thread termination
Hi all, Does any one know how to terminate or kill a thread that is started with "start_new_thread()" in the middle of its execution? Any pointers? Thanks in advance Teja. -- http://mail.python.org/mailman/listinfo/python-list
COM error
What is "ValueError: argument is not a COM object" ? I get this error when I try to pass a COM object to a thread. Any pointers Thanks Teja -- http://mail.python.org/mailman/listinfo/python-list
terminate execfile
How to terminate execfile() in the middle of its execution. Any pointers ??? Its very urgent please Thanks Teja.P -- http://mail.python.org/mailman/listinfo/python-list
Re: terminate execfile
Teja wrote: > How to terminate execfile() in the middle of its execution. Any > pointers ??? > Its very urgent please > > > Thanks > Teja.P Can I raise an interrupt using PyErr_SetInterrupt??? Is so , does any one know how to do it? -- http://mail.python.org/mailman/listinfo/python-list
Attribute error
Hi all, What is attribute error? what causes that error, especially with COM objects? To be precise : Attribute Error: LCAS.LabcarController.writeLogWindow() Here, LCAS is a COM object Thanks Teja.P -- http://mail.python.org/mailman/listinfo/python-list
COM and threads
HI all, I have a problem in accesing COM objects in threads. To be precise, lets assume that I have a class GenericFunctions which is defined as follows: import win32com.client, pythoncom, thread ie=win32com.client.Dispatch('internetexplorer.application') ie.Visible=1 class GenericFunctions: def __init__(self): print "In Constructor of Generic Functions" def MyNavigate(self,dest): ie.Navigate(dest) Now there is another file Main.py which is defined as follows: import win32com.client, pythoncom, thread from GenericFunctions import * obj = GenericFunctions() class Mainclass: def __init__(self); print "In Constructor of Main class" def threadFunction(self,dest): pythoncom.CoInitialize() d=pythoncom.CoGetInterfaceAndReleaseStream(s, pythoncom.IID_IDispatch) my_ie=win32com.client.Dispatch(d) obj.func(dest) # this is gving an error. pythoncom.CoUninitialize() if __name__ == "__main__": s=pythoncom.CoMarshalInterThreadInterfaceInStream(pythoncom.IID_IDispatch,ie) thread.start_new_thread(self.nav, (s,'www.google.com') Basically, I want to access object of GenericFunctions class inside threadFunction(). However I was able to execute my_ie.Navigate("google.com"). But that was not I wanted. I am not knowing where the error is Please let me know the solution ASAP... Teja.P -- http://mail.python.org/mailman/listinfo/python-list
Re: Attribute error
Max Erickson wrote: > "Teja" <[EMAIL PROTECTED]> wrote: > > > Hi all, > > > > What is attribute error? what causes that error, especially with COM > > objects? > > > > To be precise : > > > > Attribute Error: LCAS.LabcarController.writeLogWindow() > > > > Here, LCAS is a COM object > > > > Thanks > > Teja.P > > > > LabcarController might be a function. See: > > http://groups.google.com/group/comp.lang.python/msg/d7341f1aedcae6d3 > > for more detail. > > hope this helps, > max HI all, I have a problem in accesing COM objects in threads. To be precise, lets assume that I have a class GenericFunctions which is defined as follows: import win32com.client, pythoncom, thread ie=win32com.client.Dispatch('internetexplorer.application') ie.Visible=1 class GenericFunctions: def __init__(self): print "In Constructor of Generic Functions" def MyNavigate(self,dest): ie.Navigate(dest) Now there is another file Main.py which is defined as follows: import win32com.client, pythoncom, thread from GenericFunctions import * obj = GenericFunctions() class Mainclass: def __init__(self); print "In Constructor of Main class" def threadFunction(self,dest): pythoncom.CoInitialize() d=pythoncom.CoGetInterfaceAndReleaseStream(s, pythoncom.IID_IDispatch) my_ie=win32com.client.Dispatch(d) obj.func(dest) # this is gving an error. pythoncom.CoUninitialize() if __name__ == "__main__": s=pythoncom.CoMarshalInterThreadInterfaceInStream(pythoncom.IID_IDispatch,ie) thread.start_new_thread(self.nav, (s,'www.google.com') Basically, I want to access object of GenericFunctions class inside threadFunction(). However I was able to execute my_ie.Navigate("google.com"). But that was not I wanted. I am not knowing where the error is Please let me know the solution ASAP... Teja.P -- http://mail.python.org/mailman/listinfo/python-list
Re: COM error
Neil Cerutti wrote: > On 2006-10-14, Teja <[EMAIL PROTECTED]> wrote: > > What is "ValueError: argument is not a COM object" ? I get this > > error when I try to pass a COM object to a thread. > > > > Any pointers > > Try passing it to Larry Bird, instead. He's bound to score some > points. > > Seriously, the function you called expected a COM object and you > passed it something else. Without seeing more code, it's hard to > be any helpfuller. > > -- > Neil Cerutti HI all, I have a problem in accesing COM objects in threads. To be precise, lets assume that I have a class GenericFunctions which is defined as follows: import win32com.client, pythoncom, thread ie=win32com.client.Dispatch('internetexplorer.application') ie.Visible=1 class GenericFunctions: def __init__(self): print "In Constructor of Generic Functions" def MyNavigate(self,dest): ie.Navigate(dest) Now there is another file Main.py which is defined as follows: import win32com.client, pythoncom, thread from GenericFunctions import * obj = GenericFunctions() class Mainclass: def __init__(self); print "In Constructor of Main class" def threadFunction(self,dest): pythoncom.CoInitialize() d=pythoncom.CoGetInterfaceAndReleaseStream(s, pythoncom.IID_IDispatch) my_ie=win32com.client.Dispatch(d) obj.func(dest) # this is gving an error. pythoncom.CoUninitialize() if __name__ == "__main__": s=pythoncom.CoMarshalInterThreadInterfaceInStream(pythoncom.IID_IDispatch,ie) thread.start_new_thread(self.nav, (s,'www.google.com') Basically, I want to access object of GenericFunctions class inside threadFunction(). However I was able to execute my_ie.Navigate("google.com"). But that was not I wanted. I am not knowing where the error is Please let me know the solution ASAP... Teja.P -- http://mail.python.org/mailman/listinfo/python-list
Re: COM and Threads
Teja wrote: > Roger Upole wrote: > > "Teja" <[EMAIL PROTECTED]> wrote: > > > > > > Roger Upole wrote: > > > > > >> "Teja" <[EMAIL PROTECTED]> wrote: > > >> > > > >> > Roger Upole wrote: > > >> > > > >> >> "Teja" <[EMAIL PROTECTED]> wrote: > > >> >> >I have an application which uses COM 's Dispatch to create a COM > > >> >> >based > > >> >> > object. Now I need to upgrade the application to a threaded one. But > > >> >> > its giving an error that COM and threads wont go together. > > >> >> > Specifically > > >> >> > its an attribute error at the point where COM object is invoked. Any > > >> >> > pointers please?? > > >> >> > > > >> >> > > >> >> An actual traceback would help. > > >> >> At a guess, when using COM in a thread > > >> >> you need to call pythoncom.CoInitialize and > > >> >> CoUninitialize yourself. > > >> >> > > >> >> Roger > > >> > > > >> > Actually Roger, this is the scenario > > >> > > > >> > I create a COM object at the beginnning of the main thread. In the sub > > >> > thread, I need to access the same instance of the COM object. If it > > >> > were a normal object ie. not a COM obj, i was able to do it. But if it > > >> > were a COM object, its giving an attribute error? Should I pass a COM > > >> > object to the thread. If so How? Please let me know ASAP... Thnks > > >> > > > >> > > >> To pass COM objects between threads, usually they'll need to be marshaled > > >> using pythoncom.CoMarshalInterThreadInterfaceInStream, and unmarshaled > > >> with pythoncom.CoGetInterfaceAndReleaseStream. > > >> > > >> Roger > > > > > > I really appreciate your quick replyCan u please let me know how to > > > do marshalling and unmarshalling or any good refrences to do it. > > > Because i tried to do it. I got some errors ans so I left it... > > > > > > Thnks again... > > > > > > > Here's a simple example using Internet Explorer. > > > > import win32com.client, pythoncom, thread > > ie=win32com.client.Dispatch('internetexplorer.application') > > ie.Visible=1 > > > > def nav(istream, dest): > > pythoncom.CoInitialize() > > d=pythoncom.CoGetInterfaceAndReleaseStream(istream, > > pythoncom.IID_IDispatch) > > my_ie=win32com.client.Dispatch(d) > > my_ie.Navigate(dest) > > pythoncom.CoUninitialize() > > > > s=pythoncom.CoMarshalInterThreadInterfaceInStream(pythoncom.IID_IDispatch,ie) > > thread.start_new_thread(nav, (s, 'www.google.com')) > > > > Roger > > Thnks a lot Roger, Its working gr8..Now, once the thread is started > with start_new_thread, is there any way to terminate it upon user's > request. I have explored and found out that there is no thread.kill(). > So wht to do now? > > Teja HI all, I have a problem in accesing COM objects in threads. To be precise, lets assume that I have a class GenericFunctions which is defined as follows: import win32com.client, pythoncom, thread ie=win32com.client.Dispatch('internetexplorer.application') ie.Visible=1 class GenericFunctions: def __init__(self): print "In Constructor of Generic Functions" def MyNavigate(self,dest): ie.Navigate(dest) Now there is another file Main.py which is defined as follows: import win32com.client, pythoncom, thread from GenericFunctions import * obj = GenericFunctions() class Mainclass: def __init__(self); print "In Constructor of Main class" def threadFunction(self,dest): pythoncom.CoInitialize() d=pythoncom.CoGetInterfaceAndReleaseStream(s, pythoncom.IID_IDispatch) my_ie=win32com.client.Dispatch(d) obj.func(dest) # this is gving an error. pythoncom.CoUninitialize() if __name__ == "__main__": s=pythoncom.CoMarshalInterThreadInterfaceInStream(pythoncom.IID_IDispatch,ie) thread.start_new_thread(self.nav, (s,'www.google.com') Basically, I want to access object of GenericFunctions class inside threadFunction(). However I was able to execute my_ie.Navigate("google.com"). But that was not I wanted. I am not knowing where the error is Please let me know the solution ASAP... Teja.P -- http://mail.python.org/mailman/listinfo/python-list
COM Error -- Urgent help
HI all, I have a problem in accesing COM objects in threads. To be precise, lets assume that I have a class GenericFunctions which is defined as follows: import win32com.client, pythoncom, thread ie=win32com.client.Dispatch('internetexplorer.application') ie.Visible=1 class GenericFunctions: def __init__(self): print "In Constructor of Generic Functions" def MyNavigate(self,dest): ie.Navigate(dest) Now there is another file Main.py which is defined as follows: import win32com.client, pythoncom, thread from GenericFunctions import * obj = GenericFunctions() class Mainclass: def __init__(self); print "In Constructor of Main class" def threadFunction(self,dest): pythoncom.CoInitialize() d=pythoncom.CoGetInterfaceAndReleaseStream(s, pythoncom.IID_IDispatch) my_ie=win32com.client.Dispatch(d) obj.func(dest) # this is gving an error. pythoncom.CoUninitialize() if __name__ == "__main__": s=pythoncom.CoMarshalInterThreadInterfaceInStream(pythoncom.IID_IDispatch,ie) thread.start_new_thread(self.nav, (s,'www.google.com') Basically, I want to access object of GenericFunctions class inside threadFunction(). However I was able to execute my_ie.Navigate("google.com"). But that was not I wanted. I am not knowing where the error is Please let me know the solution ASAP... Teja.P -- http://mail.python.org/mailman/listinfo/python-list
Re: COM Error -- Urgent help
Méta-MCI wrote: > Hi! > > > .func( is not defined... > > > @-salutations > -- > Michel Claveau I am sorry. By func(dest) I meant MyNavigate(dest). Can u please help me out... Thnks, Teja.P -- http://mail.python.org/mailman/listinfo/python-list
Re: COM Error -- Urgent help
Fredrik Lundh wrote: > Teja wrote: > > > I am sorry. By func(dest) I meant MyNavigate(dest). Can u please help > > me out... > > nobody here can read your mind. please post the code you're actually > using, *and* the error you're getting. > > Thnks for your immediate reply. Here is the code: I have a class GenericFunctions which is defined as follows: import win32com.client, pythoncom, thread ie=win32com.client.Dispatch('internetexplorer.application') ie.Visible=1 class GenericFunctions: def __init__(self): print "In Constructor of Generic Functions" def MyNavigate(self,dest): ie.Navigate(dest) Now there is another file Main.py which is defined as follows: import win32com.client, pythoncom, thread from GenericFunctions import * obj = GenericFunctions() def threadFunction(self,dest): pythoncom.CoInitialize() d=pythoncom.CoGetInterfaceAndReleaseStream(s, pythoncom.IID_IDispatch) my_ie=win32com.client.Dispatch(d) obj.MyNavigate(dest) # this is gving an error. pythoncom.CoUninitialize() if __name__ == "__main__": s=pythoncom.CoMarshalInterThreadInterfaceInStream(pythoncom.IID_IDispatch,ie) thread.start_new_thread(self.nav, (s,'www.google.com') I am getting an attribute error -- http://mail.python.org/mailman/listinfo/python-list
Re: COM Error -- Urgent help
Dennis Lee Bieber wrote: > On 17 Oct 2006 00:58:59 -0700, "Teja" <[EMAIL PROTECTED]> declaimed > the following in comp.lang.python: > > >thread.start_new_thread(self.nav, (s,'www.google.com') > > > > I am getting an attribute error > > That can not be the REAL code... I'd expect a syntax error... You > have mismatched parens on that line! > -- > WulfraedDennis Lee Bieber KD6MOG > [EMAIL PROTECTED] [EMAIL PROTECTED] > HTTP://wlfraed.home.netcom.com/ > (Bestiaria Support Staff: [EMAIL PROTECTED]) > HTTP://www.bestiaria.com/ Hi, Ya its a copy paste error... But can u please let me know what is the reason for attribute error and how to rectify it?? Thnks, Regards Teja.P -- http://mail.python.org/mailman/listinfo/python-list
Re: COM Error -- Urgent help
Diez B. Roggisch wrote: > Teja wrote: > > > > > Dennis Lee Bieber wrote: > >> On 17 Oct 2006 00:58:59 -0700, "Teja" <[EMAIL PROTECTED]> declaimed > >> the following in comp.lang.python: > >> > >> >thread.start_new_thread(self.nav, (s,'www.google.com') > >> > > >> > I am getting an attribute error > >> > >> That can not be the REAL code... I'd expect a syntax error... You > >> have mismatched parens on that line! > >> -- > >> Wulfraed Dennis Lee Bieber KD6MOG > >> [EMAIL PROTECTED][EMAIL PROTECTED] > >> HTTP://wlfraed.home.netcom.com/ > >> (Bestiaria Support Staff:[EMAIL PROTECTED]) > >> HTTP://www.bestiaria.com/ > > > > Hi, > > > > Ya its a copy paste error... But can u please let me know what is the > > reason for attribute error and how to rectify it?? > > How many times need you a beating with a clue-stick? > > Post the _actual_ code, not something that closely resembles it - in _your_ > opinion > > Post the error message > > And before you do all this, read: > > http://www.catb.org/~esr/faqs/smart-questions.html > > Diez OK Ok .. Here is the final code thats giving an error: GenericFunctions.py -- import win32com.client, pythoncom, thread ie=win32com.client.Dispatch('internetexplorer.application') ie.Visible=1 class GenericFunctions: def __init__(self): print "In Constructor of Generic Functions" def MyNavigate(self,dest): ie.Navigate(dest) --- MainThread.py -- import win32com.client, pythoncom, thread from GenericFunctions import * obj = GenericFunctions() import sys,traceback def threadFunction(s,dest): pythoncom.CoInitialize() try: d=pythoncom.CoGetInterfaceAndReleaseStream(s, pythoncom.IID_IDispatch) my_ie=win32com.client.Dispatch(d) #d.MyNavigate(dest) obj.MyNavigate(dest) # this is gving an error. except: my_ie = None print traceback.print_exc(file= sys.stdout) pythoncom.CoUninitialize() if __name__ == "__main__": s=pythoncom.CoMarshalInterThreadInterfaceInStream(pythoncom.IID_IDispatch,ie) thread.start_new_thread(threadFunction, (s,'www.google.com')) - And here is the error: Traceback (most recent call last): File "C:\Documents and Settings\dzxbrn\Desktop\Stop Test\13 Oct\MainThread.py", line 13, in threadFunction obj.MyNavigate(dest) # this is gving an error. File "C:\Documents and Settings\dzxbrn\Desktop\Stop Test\13 Oct\GenericFunctions.py", line 9, in MyNavigate ie.Navigate(dest) File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 489, in __getattr__ raise AttributeError, "%s.%s" % (self._username_, attr) AttributeError: internetexplorer.application.Navigate None This is highly urgent and important... Please help me out Thnks & Regards, Tejovathi.P -- http://mail.python.org/mailman/listinfo/python-list
Re: COM Error -- Urgent help
This is the trae back ,can you help me please. Traceback (most recent call last): File "C:\Documents and Settings\dzxbrn\Desktop\Stop Test\13 Oct\MainThread.py", line 13, in threadFunction obj.MyNavigate(dest) # this is gving an error. File "C:\Documents and Settings\dzxbrn\Desktop\Stop Test\13 Oct\GenericFunctions.py", line 9, in MyNavigate ie.Navigate(dest) File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 489, in __getattr__ raise AttributeError, "%s.%s" % (self._username_, attr) AttributeError: internetexplorer.application.Navigate None Fredrik Lundh wrote: > Teja wrote: > > > s=pythoncom.CoMarshalInterThreadInterfaceInStream(pythoncom.IID_IDispatch,ie) > > > >thread.start_new_thread(self.nav, (s,'www.google.com') > > > > I am getting an attribute error > > the traceback tells you what attribute Python was looking for, and may also > provide > additional clues. can you post the traceback too? make sure you include all > of it. > > -- http://mail.python.org/mailman/listinfo/python-list
Get coordinates of a cell
I have a GUI application with a Frame and a grid in it. I want to popup a menu after the user enters some text in a cell and hits ENTER key. I was able to popup the menu. However the menu is not popping up exactly at the position where I want it. It should be popped up immediately after the cell in which the user has entered the text. To get the co ordinates I am using the function event.GetPosition(). Here event is wx.EVT_KEY_DOWN. Any pointers please? -- http://mail.python.org/mailman/listinfo/python-list
Regular Expression for a string
HI all, I need to write a regular experssion for a string which satisfies the following a criteria : 1) it should start with an alphabet 2) it can contain alphabets/digits/_ from second character 3) it can contain "[a-z]" or "[0-9]" at the end. but this is optional can any one please help me out pls Teja.P -- http://mail.python.org/mailman/listinfo/python-list
Re: Regular Expression for a string
James Stroud wrote: > Teja wrote: > > HI all, > > > > I need to write a regular experssion for a string which satisfies the > > following a criteria : > > > > 1) it should start with an alphabet > > 2) it can contain alphabets/digits/_ from second character > > 3) it can contain "[a-z]" or "[0-9]" at the end. but this is optional > > > > can any one please help me out pls > > > > > > Teja.P > > > > This is as general as could be constructed given your vague requirements: > > "[a-zA-Z][a-zA-Z0-9_]+" > > You may need to provide examples. > > James > > > > -- > James Stroud > UCLA-DOE Institute for Genomics and Proteomics > Box 951570 > Los Angeles, CA 90095 > > http://www.jamesstroud.com/ Thnks James for ur quick reply. Here is what I want actually Some examples string1 string_1 string1[0] string_1_str[a] STRING_1_[2] STRING_1_str[a][1][2] etc etc I need a regular expression for such strings -- http://mail.python.org/mailman/listinfo/python-list
Re: Regular Expression for a string
Roy Smith wrote: > In article <[EMAIL PROTECTED]>, > "Teja" <[EMAIL PROTECTED]> wrote: > > > HI all, > > > > I need to write a regular experssion for a string which satisfies the > > following a criteria : > > > > 1) it should start with an alphabet > > I assume you mean, "It should start with a letter"? > > > 2) it can contain alphabets/digits/_ from second character > > 3) it can contain "[a-z]" or "[0-9]" at the end. but this is optional > > How about: ^[a-zA-Z][a-zA-Z0-9_]*[a-z0-9]?$ > > Probably many variations on that theme will also work. Thnks Roy for ur quick reply. Here is what I want actually Some examples string1 string_1 string1[0] string_1_str[a] STRING_1_[2] STRING_1_str[a][1][2] etc etc I need a regular expression for such strings -- http://mail.python.org/mailman/listinfo/python-list
Re: Regular Expression for a string
John Machin wrote: > Teja wrote: > > HI all, > > > > I need to write a regular experssion for a string which satisfies the > > following a criteria : > > > > 1) it should start with an alphabet > > 2) it can contain alphabets/digits/_ from second character > > 3) it can contain "[a-z]" or "[0-9]" at the end. but this is optional > > Based on the examples you give later, you don't mean "optional" (0 or 1 > occurrences), you mean 0 or more occurrences. > Assuming "alphabet" means "English alphabetic": > > r"[a-zA-Z][a-zA-Z0-9_]*(\[[a-z0-9]\])*" > > HTH, > John Thnks a lot:) -- http://mail.python.org/mailman/listinfo/python-list
Helpbook and CHM
How to create a helpbook and display it using python(in Boa). Also, how to generate CHM files in Boa(Python)??? Any pointers please -- http://mail.python.org/mailman/listinfo/python-list
Re: Helpbook and CHM
On Apr 19, 3:48 pm, Tim Golden <[EMAIL PROTECTED]> wrote: > Teja wrote: > > how to generate CHM files in Boa(Python)??? > >http://www.rutherfurd.net/software/rst2chm/index.html > > TJG Can't I do it in Boa constructor ??? I have seen an option in Boa to create a new helpbook and compile it to CHm and help files, But no clue how to do it... -- http://mail.python.org/mailman/listinfo/python-list
Re: Helpbook and CHM
On Apr 19, 4:33 pm, Ravi Teja <[EMAIL PROTECTED]> wrote: > On Apr 19, 3:58 am, Teja <[EMAIL PROTECTED]> wrote: > > > On Apr 19, 3:48 pm, Tim Golden <[EMAIL PROTECTED]> wrote: > > > > Teja wrote: > > > > how to generate CHM files in Boa(Python)??? > > > >http://www.rutherfurd.net/software/rst2chm/index.html > > > > TJG > > > Can't I do it in Boa constructor ??? I have seen an option in Boa to > > create a new helpbook and compile it to CHm and help files, But no > > clue how to do it... > > Not that I know of. Which version are you using? Where in the > application did you find it? Indicate the menu's you navigated to get > to that option. > > MS HTML Help Workshop is the standard compiler for CHM files. There > are some other freeware/shareware. The workshop is simple enough > though. If u have Boa constructor 0.4.4, Go to File--->New--->helpbook Save it. After saving, click File menu option and you will find, "make HTB" and "make CHM" But I dont know how to add files and generate a complete CHM file. -- http://mail.python.org/mailman/listinfo/python-list
Kill thread
Hi all, Can any on help me out in killing a thread (i.e deleteing the reources like, stack ,memory etc) which is started with win32process.beginthreadex()??? Rite now, I am suspending the thread. But any pointers as to how to delete the thread permanently? Its pretty urgent... Please... Teja.P -- http://mail.python.org/mailman/listinfo/python-list
Re: Kill thread
On Apr 9, 3:01 pm, Michel Claveau <[EMAIL PROTECTED]> wrote: > Hi! > > If you have the PID of the process (example: 1234), use this > command-line : >TASKKILL/F /PID 1234 > > -- > @-salutations > > Michel Claveau Hi Michel, Thnks for the replyBut TASKKILL kills the process entirely..Not the thread. I want only the thread to be killed. Actually I am starting the thread in main thread. I jus want to kill the child thread and keep the main thread running. With TASKKILL, the main thread is also exited...I dont want it to happen.. Wht do i do?? Awaiting for a reply Teja.P -- http://mail.python.org/mailman/listinfo/python-list
Re: Kill thread
On Apr 9, 6:18 pm, "Christian" <[EMAIL PROTECTED]> wrote: > On Apr 9, 5:14 am, "Teja" <[EMAIL PROTECTED]> wrote: > > > Hi all, > > > Can any on help me out in killing a thread (i.e deleteing the reources > > like, stack ,memory etc) which is started with > > win32process.beginthreadex()??? > > > Rite now, I am suspending the thread. But any pointers as to how to > > delete the thread permanently? > > > Its pretty urgent... Please... > > > Teja.P > > Well, the answer with Python threads is that you don't kill them - you > ask them to go away. But since you are using something in the pywin32 > package, that rule might not apply. Perhaps you would have better > luck asking on the python-win32 > list:http://mail.python.org/mailman/listinfo/python-win32 > > Christianhttp://www.dowski.com Can TASKKILL kill threads? For the TASKKILL command TASKKILL /F /PID 1234 , I gave thread id instead of PID It didnt throw any error. Does that mean that thread is really killed, releasing all its resources> How can I ensure that the thread is killed? -- http://mail.python.org/mailman/listinfo/python-list
TASK KILL
Will TASKKILL kills a thread when thread id is given ?? Or does it kill only a process?? How to ensure that a thread is killed? -- http://mail.python.org/mailman/listinfo/python-list
COM server and EXE
Hi All, I have a Python COM server. I need to deploy it on various sytems. When I run the COM server from python its showing an output " Registered : sample.lib" If I try to use the COM obj from a VB client like: obj = CreateObject("sample.lib") Its working fine without any errors Now I am trying to convert this COM server to an exe through py2exe and after I run the exe, I am getting the same output " Registered : sample.lib" But If I try to use the COM obj from a VB client like obj = CreateObject("sample.lib") A console pops up saying " Registered : sample.lib" and VB application hangs there. Its throwing a VB error that "ActiveX object cannot be created..etc etc" Any suggestions please... Regards, Tejovathi -- http://mail.python.org/mailman/listinfo/python-list
Re: COM server and EXE
On Jan 8, 3:33 pm, Teja <[EMAIL PROTECTED]> wrote: > Hi All, > > I have a Python COM server. I need to deploy it on various sytems. > When I run the COM server from > python its showing an output " Registered : sample.lib" > > If I try to use the COM obj from a VB client like: > > obj = CreateObject("sample.lib") > > Its working fine without any errors > > Now I am trying to convert this COM server to an exe through py2exe > and after I run the exe, I am > getting the same output " Registered : sample.lib" > > But If I try to use the COM obj from a VB client like > > obj = CreateObject("sample.lib") > > A console pops up saying " Registered : sample.lib" and VB application > hangs there. > Its throwing a VB error that "ActiveX object cannot be > created..etc etc" > > Any suggestions please... > > Regards, > Tejovathi Here is my sample COM server and py2exe setup file testCOM.py import win32com.client import os.path import shutil from win32api import Sleep import string import os import sys import pythoncom class FirstEx: _reg_clsid_ = "{A6DE9DF8-5EBF-48E6-889E-C71CB84CFF2C}" pythoncom.frozen = 1 if hasattr(sys, 'importers'): # In the py2exe-packed version, specify the module.class # to use. In the python script version, python is able # to figure it out itself. _reg_class_spec_ = "__main__.FirstEx" _reg_desc_ = "My first COM server" _reg_progid_ = "SAMPLE.Lib" _public_methods_ = ['init', 'Version'] _public_attrs_ = ['softspace', 'noCalls'] _readonly_attrs_ = ['noCalls'] _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER def __init__(self): self.softspace = 1 self.noCalls = 0 def Version(self): self.noCalls = self.noCalls + 1 # insert "softspace" number of spaces return "Version: 0.0.1" if __name__=='__main__': import sys if hasattr(sys, 'importers'): # running as packed executable. if '--register' in sys.argv[1:] or '--unregister' in sys.argv[1:]: # --register and --unregister work as usual import win32com.server.register win32com.server.register.UseCommandLine(FirstEx) else: # start the server. from win32com.server import localserver localserver.main() else: import win32com.server.register win32com.server.register.UseCommandLine(FirstEx) Here is my setup file: #Start here from distutils.core import setup import py2exe setup(options = {"py2exe": {"compressed": 1, "optimize": 2, "ascii": 1, "bundle_files": 1}}, zipfile = None, com_server = ["win32com.servers.interp"], console = ["testCOM.py"]) #End here Here is my VB code: Sub subRoutine() Dim connection As Object Dim returnvalue1 As String Dim returnvalue2 As String Dim flag3 As Boolean Set connection = CreateObject("SAMPLE.Lib") returnvalue1 = connection.Version() MsgBox (returnvalue1) End Sub The non exe version of the COM server ie. directlly running the testCOM.py registers the library properly and in the VB application, the message box displays the version as 0.0.1. But, after I create the EXE file using the setup.py file and run it, it registers the library. When I run the VB application, it hangs at the line Set connection = CreateObject("SAMPLE.Lib") and displays. " ACTIVEX cannot create the object" Any suggestions please -- http://mail.python.org/mailman/listinfo/python-list
Regarding Threads and locals()
Hi all, I have a GUI applicaion(along with threads). When the run button is pressed in the GUI a separate thread starts( Thread is created using beginthreadex) and does the required activity. Now, while the thread is being executed, i want the locals() present inside the thread's run function to be avaialbe in the GUI class from where the thread class is being created EG: -- main.py -- class WorkerThread(threading.Thread): def __init__(self, ): threading.Thread.__init__(self) # Start the thread and invoke the run method self.start() def run(self): # Start the thread. It executed self.func() as a separate thread self.workerThread, tid = win32process.beginthreadex(None, 0 , self.func ,(), 1) ... def func(self): execfile(temp.py) class GUI(wxFrame): def __init__(self): . . def CreateThread(self): self.workerThread = WorkerThread() if name == _main_: . . .. - temp.py -- i = 1 j = 2 k = 4 while(1): print i print j print k i = 1+1 j = j+2 k = k + 3 Now, while the thread is executin func and printing i, j, k , In the main GUI thread how do i get the values of i, j ,k I tried with sys.modules, sys._current_frames, vars(). But nothing worked out. Ideally the locals() of func() should be passed to the GUI thread, how? -- http://mail.python.org/mailman/listinfo/python-list
Re: copy file over LAN
On Mar 27, 8:34 am, Astan Chee <[EMAIL PROTECTED]> wrote: > Hi, > I have afileon another machine on the localnetwork(my machine and > local machines are on windows) and I want tocopyit locally. Now the > machine requires authentication and when I try to do a > import shutil > shutil.copy(r'\\remotemachine\c$\temp\filename',r'C:\folder\test.txt') > and it gives me a IOError: [Errno 13] Permission denied: error, which I > expect. How do I provide authentication tocopythisfile? > Thanks for the help. > Cheers > Astan > > -- > "Formulations of number theory: Complete, Consistent, Non-trivial. Choose > two." > > Animal Logichttp://www.animallogic.com > > Please think of the environment before printing this email. > > This email and any attachments may be confidential and/or privileged. If you > are not the intended recipient of this email, you must not disclose or use > the information contained in it. Please notify the sender immediately and > delete this document if you have received it in error. We do not guarantee > this email is error or virus free. Hi, Is the folder where the file is present i.e. "temp" in your case, shared Can you share it and try it?? I tried this way and it worked! import shutil shutil.copyfile(r'\\129.124.66.112\Samplesharedfolder\samplefile.txt', r'C:\\Test\\temppp.txt') Try this way and let me know -- http://mail.python.org/mailman/listinfo/python-list
Archiving emails in Gmail
Hi, I have a requirement that I want to log-in into a gmail account read all unread mails, mark them as read and then archive them. I am using libgmail (version 0.1.11) library to do so, using which I am able to log-in into a gmail account fetch all unread message and then read them one by one. Now my problem is that I am not able to mark the unread mail as read and archive it. Below is sample code that I am using. from libgmail import * ARCHIVE_ACTION='rc_^i' #the action string to archive a message UNREAD_MAILS = "is:unread" def ArchiveAll(): ga = GmailAccount(name='username', pw='password') print 'logging in...', ga.login() print 'successful' def _getAllUnreadMails(): return ga.getMessagesByQuery(UNREAD_MAILS, True) def _readMail(email): emailData = ga.getRawMessage(email) def _archiveAndMarkRead(email): ga._doThreadAction(ARCHIVE_ACTION, email) ga._doThreadAction(U_MARKREAD_ACTION, email) emails = _getAllUnreadMails() for email in emails: eData = _readMail(email) #Process email data _archiveAndMarkRead(email) print 'done' if __name__ == '__main__': ArchiveAll() after executing this code I am getting following error HTTP Error 500: Internal Server Error Traceback (most recent call last): File "test_libgmail.py", line 30, in ArchiveAll() File "test_libgmail.py", line 26, in ArchiveAll [_archiveAndMarkRead(t) for t in sr[1]] File "test_libgmail.py", line 21, in _archiveAndMarkRead ga._doThreadAction(ARCHIVE_ACTION, thread) File "/home/3rdparty/libgmail/libgmail.py", line 669, in _doThreadAction items = self._parsePage(_buildURL(**params)) File "/home/3rdparty/libgmail/libgmail.py", line 383, in _parsePage items = _parsePage(self._retrievePage(urlOrRequest)) File "/home/3rdparty/libgmail/libgmail.py", line 99, in _parsePage lines = pageContent.splitlines() AttributeError: 'NoneType' object has no attribute 'splitlines' Can anyone help me in figuring out what's going wrong here? I guess google has deprecated this way of marking emails, correct me if I am wrong here. But if its true, is there any other way or library in Python to meet my requirements? Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list
Re: Archiving emails in Gmail
Ohh my bad... thanks a lot for replying Alf.. The error which I've pasted above, was thrown before I modified the code a bit.. Here's the error thrown on running the code I've pasted above.. there's not much of a difference in the error though. HTTP Error 500: Internal Server Error Traceback (most recent call last): File "test_libgmail.py", line 40, in ArchiveAll() File "test_libgmail.py", line 35, in ArchiveAll _archiveAndMarkRead(email) File "test_libgmail.py", line 28, in _archiveAndMarkRead ga._doThreadAction(ARCHIVE_ACTION, email) File "/home/3rdparty/test/libgmail/libgmail.py", line 670, in _doThreadAction items = self._parsePage(_buildURL(**params)) File "/home/3rdparty/test/libgmail/libgmail.py", line 384, in _parsePage items = _parsePage(self._retrievePage(urlOrRequest)) File "/home/3rdparty/test/libgmail/libgmail.py", line 99, in _parsePage lines = pageContent.splitlines() AttributeError: 'NoneType' object has no attribute 'splitlines' I tried to debug the issue here, when self._retrievePage(urlOrRequest) is called (it is called internally in libgmail) a 500 internal server error is thrown. And hence further processing on the response can not be done. I also caught the url which throws 500: https://mail.google.com/mail/?ui=1&search=all&t=129374b41acebfcd&view=up&at=&act=rc_^i Now I don't know why 500 is thrown and on which side the exact problem lies, i.e. the libgmail side or the gmail side. And there's a email library provided in Python (supports both POP and SMTP) but I dont know whether it allows us to archive mails or mark them as read for that matter. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Python weak on the web side?
Too many options. Google: python web frameworks The first couple of links will point you to enough resources. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there an equivalent to Java Webstart in Python?
Hi Kent, Too complicated example :-). Jythonc works just fine to create a regular jar file that you can reference in your jnlp file. Ravi Teja. -- http://mail.python.org/mailman/listinfo/python-list
Re: Embedding Python in other programs
http://www.python.org/windows/win32com/QuickStartServerCom.html If you are using ActivePython, that tutorial is included (PyWin32 documentation -> Python COM -> Overviews) along with the needed win32all module. -- http://mail.python.org/mailman/listinfo/python-list
Re: Embedding Python in other programs
Greg, I don't recall touching VB6 in 4 years. From whatever I remember, you are trying to do early binding (trying to find a registered type library). You need to do late binding instead (use CreateObject) to dynamically instantiate the COM object. Ravi Teja. -- http://mail.python.org/mailman/listinfo/python-list
Re: Extend Python
SIP is not a commercial product and is released on a different license than PyQt. >From the SIP docs (http://www.river-bank.demon.co.uk/docs/sip/sipref.html#license) 1.1 License SIP is licensed under the same terms as Python itself. SIP places no restrictions on the license you may apply to the bindings you create. On a side note.. there will be a GPL edition of PyQt sometime in the future. http://www.riverbankcomputing.co.uk/pyqt/roadmap.php -- http://mail.python.org/mailman/listinfo/python-list
Re: Visual Python, really "Visual"?
No! Visual Python does not have a WYSIWYG GUI Builder. Boa Constructor is the closest. PythonCard is another contender. Once, XAML comes in, this will become less of an issue. -- http://mail.python.org/mailman/listinfo/python-list
Re: Still Loving Python
Nothing beats Delphi for the raw design speed and choices for GUI development. .NET is another good option. The good news is you don't have to loose their benefits just because we chose Python. Python for Delphi works quite well to get you the best of both worlds. I develop the app in Python as a library first (Python is great for quick prototyping), make my GUI in Delphi and simply call my library from it. Bundling Python manually into an installer can be a chore but you will get used to it. Once IronPython is complete, it should do the same for .NET. I currently use Boo in a similar fashion. For simpler UIs, libglade does a great job of seperating concerns. > Are there any easy GUI > builders for any Python-supported toolkits? Most UI toolkits have sort of builders GTK - Glade wxWindows - wxGlade Fox - Fox Dialog Editor FLTK - Fluid TkInter - SpecTcl (I think I remember it exporting to Python) Ofcourse, none are as robust as Delphi's. -- http://mail.python.org/mailman/listinfo/python-list
Re: scrape url out of brackets?
Regular Expressions are the most common way. http://docs.python.org/lib/module-re.html HTML parser is another http://docs.python.org/lib/module-htmllib.html -- http://mail.python.org/mailman/listinfo/python-list
Re: IDE for Python ?
[EMAIL PROTECTED] wrote: > I'm getting realy tired of learning new languages. > And especially frustrated at the 'syntax errors' when switching > between them. > > There are basically only a few common concepts needed for > all the languages. Hence linux's p2c: Pascal to C translator. > > A good IDE could hide the irrelevant details of the syntax, > much like DOS/Norton-commander--Linux/mc hides the > details, and makes visual, the common actions on files: > move, copy, view ...edit ...search etc. > > Besides, I guess Python itself would be good to make such > an IDE ? Is there any such tool available/recomended ? > > == Chris Glur. You obviously have not learnt many languages. First you have a very wrong notion that all languages are very similar. Pascal and C are similar languages (Hence P2C, BCX etc). But Pascal and C do not constitute *all* languages. There is a world of a difference between (Lisp and C) or (Haskell and Pascal) or (Prolog and Javascript). The differences between languages is not syntax but the theory and the favored model of solving problems behind them. Java, for example favors problem decomposition into objects. Lisp primarily decomposes problems to lists. Prolog to rules. Haskell to functions etc. Model representation (syntax) is secondary to this model. It is possible to represent problems at a higher level for a given model. For example OOP models can be represented in UML. MDA attempts to create executable programs based on these abstract models. These typically succeed only in well defined domains as 4GL tools. Can there be a common rendition between models of all languages? Yes. It is called machine code / byte code and it does not *hide* details from you. It is the detail. That is the marketing buzz behind .NET's CLR. Similarly there are about 200 languages / mini languages that compile to Java byte code. There have been attempts to create point and click tools for low level programming constructs like if clauses and for loops in the past. I came across atleast one for Java. I cannot remember the name now. Needless to say, none have succeeded. In short, there is no escape. If you want to create software, you must learn languages. The more you know (from different models), the better software you create, even if you can't use them all. -- http://mail.python.org/mailman/listinfo/python-list
Re: Re.'Compressing folders in Windows using Python'
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/299412 -- http://mail.python.org/mailman/listinfo/python-list
Re: Python for Lazarus (not Delphi)
Uwe Grauer wrote: > Does anyone know if something similar to Python for Delphi > does exist for lazarus? > > Thanks for any pointers, > Uwe Python for Delphi does support Lazarus since Version 3.29 http://mmm-experts.com/VersionHistory.aspx?ProductId=3 -- http://mail.python.org/mailman/listinfo/python-list
Re: python and JMS
> I am looking to use python to talk to JMS. Can some please point me to > such resources if this is possible. JPype http://jpype.sourceforge.net/ Jython http://www.jython.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: python and JMS
Alan Kennedy wrote: > [tksri2000] > > I am looking to use python to talk to JMS. Can some please point me to > > such resources if this is possible. > > PyHJB is the python-to-JMS gateway. ... via HJB, the HTTP JMS bridge. > http://hjb.python-hosting.com/ > > HJB (HTTP JMS Bridge) > http://hjb.berlios.de/ Neat. Apparently ActiveMQ supports multi-language clients through STOMP too. http://www.activemq.org/site/cross-language-clients.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Programming newbie coming from Ruby: a few Python questions
> 'Clever is not considered a compliment in Python.' (don't know where I > read that...) On a similar note. "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." -- Brian Kernighan of C -- http://mail.python.org/mailman/listinfo/python-list
Re: Programming newbie coming from Ruby: a few Python questions
> Is this kind of cleverness what is usually known as "magic"? > I suspect that this has something to do with it, but not completely > sure... :-). It must be. Now Django has a "magic removal branch". -- http://mail.python.org/mailman/listinfo/python-list
Re: New to Python-- Help
Philippe Martin wrote: > John & Mary Cook wrote: > > > I just installed Python on Windows XP Pro. When I enter 'python' at the > > >>> prompt in Pythonwin IDE I get the following: > > > > Traceback (most recent call last): > >File "", line 1, in ? > > Name Error: name 'python' is not defined > > > > Can anyone help? > > > > Thank you, > > > > J. T. Cook > > Did you install Python, or Pythonwin ? > > Cannot use #2 without #1. He probably used ActivePython. It includes both. Besides PythonWin IDE won't start without Python :-) John: Try this tutorial. It does not assume a programming background. http://honors.montana.edu/~jjc/easytut/easytut/ You already started Python when you started PythonWin IDE. You won't need to type python in it again :-) In the tutorial I linked, PythonWin is analogous to IDLE (another IDE) mentioned in it. You should also have IDLE installed in your menus. -- http://mail.python.org/mailman/listinfo/python-list
Re: The decentralized nature of the Python community is driving me crazy
> But I must say the one thing I miss about Perl is my ability to stay on > top of all the latest modules and apps in one place: CPAN. With Python, > code is EVERYWHERE - people's local boxes, sourceforge, freshmeat, > codezoo, parnassus, etc, etc. Python CheeseShop is equivalent to CPAN http://www.python.org/pypi Easy Install provides a nice client http://peak.telecommunity.com/DevCenter/EasyInstall -- http://mail.python.org/mailman/listinfo/python-list
Re: Easy to use distributed system?
Jim Jones wrote: > I am looking for a system in Python that will easily allow me to distribute > processes across multiple systems?So, if I have a function 'foo', I'd > like to be able to call something along the lines of > > distribute(foo(x)) > > And have the system figure out which node is available for process, and then > have the results returned in some sort of callback fashion. > > Any insight is greatly appreciated. Sounds like Grid computing. Google for Globus toolkit and ActiveGrid. Good luck. -- http://mail.python.org/mailman/listinfo/python-list
Re: recommended general-purpose string template packages?
> In general, I'm mainly interested in a template engine for dynamic web > pages but would like a general purpose one to avoid learning yet > another package for generating e-mail messages, form letters, source > code, whatever. > > In particular, does anyone have much experience with the Python > interface to Terence Parr's StringTemplate > (http://www.stringtemplate.org/)? Reading the website, I'm attracted by > the approach, but a Google search (both generally and in this > newsgroup) gives me the impression that it's little used in the Python > world. Most Python templating engines are general purpose. Choice between them however is sometimes a matter of preference, like editors. I settled down on Cheetah for most part. Here is a list of some popular ones. http://wiki.python.org/moin/Templating -- http://mail.python.org/mailman/listinfo/python-list
Re: sqlite3 or mysqldb?
> To learn SQL SQLite should be enough - it has all the basics, just as > MySQL, while it doesn't require any server/client configuration > (encoding configuration in MySQL is real PITA). But if you want any > "serious SQL", go with any freely available *real SQL server*, like > Firebird or PostgreSQL. I'd consider Firebird, as it's pretty lightweight. Firebird can be used as an embedded database just like SQLite as well. This gives a much more powerful database that can still be used without the administration overhead. Aside from flexibility, the reason I prefer FireBird is that it has much more sophisticated visual tools available. -- http://mail.python.org/mailman/listinfo/python-list
Re: Text to MP3 using pyTTS - Non-programmer question
[EMAIL PROTECTED] wrote: > Thanks for the script. Are there any online python intrepreters? > > I'd like to play around with the script. I don't have access to my home > PC. You probably will have to wait till you get to yours. There were some AJAXian ones but I doubt that you will find a free (assuming that you meant that) online interpreter on a MS Windows box that allows you to install your modules and give you an FTP or such account to get the recorded file back. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to catch these kind of bugs in Python?
asincero wrote: > Is there anyway to catch the following type of bug in Python code: > > message = 'This is a message' > # some code > # some more code > if some_obscure_condition: >nessage = 'Some obscure condition occured.' > # yet more code > # still more code > print message > > > In the above example, message should be set to 'Some obscure condition > occured.' if some_obscure_condition is True. But due to a lack of > sleep, and possibly even being drunk, the programmer has mistyped > message. These types of bugs would easily be caught in languages that > have a specific keyword or syntax for declaring variables before use. > I'm still fairly new to using Python on a more than casual basis, so I > don't know if Python has anyway to help me out here. The keyword is "obscure condition". The solution is to use a coverage tool and create unit tests that give you 100% code coverage. -- http://mail.python.org/mailman/listinfo/python-list
Re: What would be the best way to run python client in the background
gel wrote: > Hi > I have written a python client server app that keeps an eye on > processes starting and ending on a client and makes decision on what to > do based on information from the server end. I want to run the client > end of the app more or less invisibly (no console) on the XP clients > when ever a users logs on. What would be the best way to get this > done? A bit more info on the purpose of the app... it is to act as a > licence server, where we have a limited number of licences for software > and the software installed on all PCs. The app will only allow a pre > defined number of clients to run the software at any one time. To run a python script without a console - use *.pyw extension. But from what you stated you perhaps don't want to do this. Whether you deploy this check as a service (through py2exe for example) or a straight script, the users may simply kill it if they want to bypass the check. Plus it is not common to use a seperate persistant process to check for licenses. A better way is to incorporate the check directly into the process of the software. -- http://mail.python.org/mailman/listinfo/python-list
Re: What would be the best way to run python client in the background
> The reason for the a seperate persistant check is because it will be > used to enable software to be installed in whole lab of PCs but only > allow a predifined number to run the software at any time one time. > And then when a user stop using the software a licence will become > available to for someone else on the same or another PC to use the > software. The reason that the process of the software being check is > not used is because it will be used for software written by other > people. I hope this makes what and why a little clearer. Let me know > if you think that I have misunderstoood you. Hmm... I don't have experience with such architecture personally. The software being managed must have some sort of dependency on the license manager if the manager is to be external. I don't know how you can reliably manage external programs that are decoupled from the license manager. You can however create a plug-in of sorts if the other authors would be willing to incorporate it without much work to them. I mostly explored license management in Delphi apps. Since Delphi is/was a Shareware favorite, it has quite a few open source / commercial components available to manage such licensing, usually with trivial effort from the component user. You could take a look at them (http://www.torry.net/quicksearchd.php?String=shareware&Title=No). Some of them might even compile on Lazarus to expose them to Python. By large, the culture of Python is open source and such expertise may not be common place here. You might want to subscribe to the mailing lists of "Association of Shareware Professionals" (http://www.asp-shareware.org/). I have not been on this path in 5 years and so am out of touch. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Editor with Autocorrection
Laurentiu wrote: > hello! > > > i am searching for a free python editor with > autocorrection capabillities. > > for example:" the wrong setfocus() call to become > SetFocus(), etc." > > > thanks Python is a dynamic language, which means that methods that may not exist in your source code may spring to being at runtime at any point. So it may be undesirable to have such feature. (For example, take a look at an XML binding tool such as Amara which creates objects at runtime after parsing an XML file). Most good editors (Scintilla based editors, Emacs, Vi etc) have auto-completion for symbols that have occured in the current file; and some advanced IDEs (PyDev, WingIDE, SPE, Komodo etc) will auto-complete to some degree based on your imports through static analysis. -- http://mail.python.org/mailman/listinfo/python-list
Re: text editor suggestion?
> I also just started using Scite, and I really like it, except I find its > syntax highlighting to be very inflexible. You aren't able to define > your own groups of words -- you have to use what's given, basically. One > thing I like about UltraEdit is that you simply define as many groups of > keywords as you want and then assign a style to each one. Scite has a > very strange and rigid method of highlighting. Stick to SciTE. It takes almost no learning effort and meets everyone of those requirements. As far as customerization goes, SciTE can be customerized quite well. In fact, it can even be scripted with Lua. You seem to be using the single file executable which does not come with the configuration files. Otherwise, I cannot see how you could be missing this ability. Try this one instead if you are on Windows. http://gisdeveloper.tripod.com/scite.html You need to edit the file python.properties to add keywords. Windows - C:\Program Files\SciTe\python.properties Debian - /usr/share/scite/python.properties -- http://mail.python.org/mailman/listinfo/python-list
Re: text editor suggestion?
John Salerno wrote: > Ravi Teja wrote: > > > Stick to SciTE. It takes almost no learning effort and meets everyone > > of those requirements. As far as customerization goes, SciTE can be > > customerized quite well. In fact, it can even be scripted with Lua. You > > seem to be using the single file executable which does not come with > > the configuration files. Otherwise, I cannot see how you could be > > missing this ability. > > I really like Scite, but I find it's syntax highlighting abilities to be > quite limited. You can't specify your own groups of words, you can only > use what is already preset in the lexer files. ??? In the same file, near the top. keywordclass.python=and assert break class continue def del elif \ else except exec finally for from global if import in is lambda None \ not or pass print raise return try while yield I could add my own keywords to it. -- http://mail.python.org/mailman/listinfo/python-list
Re: text editor suggestion?
John Salerno wrote: > Ravi Teja wrote: > > > ??? > > > > In the same file, near the top. > > > > keywordclass.python=and assert break class continue def del elif \ > > else except exec finally for from global if import in is lambda None \ > > not or pass print raise return try while yield > > > > I could add my own keywords to it. > > > > But I don't want all my keywords to be highlighted in the same way. I > have different colors for Python keywords, functions and methods, > exceptions, other words like 'self', etc. and there's no way to do this > without rewriting the lexer file (which is in C++) and recompiling Scite > to build the changes into it. I don't know if SciTE somehow supports function highlighting but the properties file for php will perhaps give you some ideas on having seperate groups with different highlight properties. I recall repurposing something similar when I used to use Spyce for web apps. http://mailman.lyra.org/pipermail/scite-interest/attachments/20050912/c9d5e51b/html-0001.obj -- http://mail.python.org/mailman/listinfo/python-list
Re: ADO with Python
Ralf wrote: > Is their anybody with xperience in using the both and can provide me with > some xamples. Googling for python ado returns this simple tutorial http://www.markcarter.me.uk/computing/python/ado.html COM access in Python is straight forward with win32all. -- http://mail.python.org/mailman/listinfo/python-list
Re: More Noob Questions
> 1) I'm also learning to program flash movies while I learn to do > python. How can one implement flash movies into their python code? Depending on what "implementing flash movies into Python code" means. Python and Flash can be complementary. You can develop the UI in Flash and have it talk to Python via web services. I suppose that you can embed the Flash Player control in a wxPython app as well and drive it from there. But such integrations typically deal with some slightly advanced issues that are best left aside in context of a beginner. -- http://mail.python.org/mailman/listinfo/python-list
Re: Rapid desktop application development
Stephen Eilert wrote: > Hi all, > > There has been much hype lately about web "megaframeworks", like > TurboGears, Django and Rails(Ruby side). Those are all fantastic > frameworks, nicely integrated so that the user can focus on solving his > problem, instead of doing all the scaffolding and framework integration > by hand. > > Now, I am not a fan of web applications so I'm creating a few GUI > applications using Python. Thanks to wxPython, those are all > native-looking, with powerful components. This is quite nice. Now, I > want to use some OR-Mapper, so I chose SQLObjects. This is nice too. I > do have to write controllers, model, and all the glue code between the > frameworks by hand. > > However, I don't have to do that with a framework such as TurboGears, > for web applications. Everything is neatly integrated so that I just > have to "fill in the blanks". It would be the same application, except > that the presentation is GUI-based, instead of Web-based. MVC > architecture too and so on. > > Are there any frameworks like those, for GUI applications? It would be > interesting to abstract away that repetitive work. Dabo http://dabodev.com/ TraitsUI http://code.enthought.com/traits/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Programming Language that is Spreadsheet/Table Based
Omar wrote: > I'm looking for a programming language or module that sorta looks and > feels like MS Excel (I love and think in tables), yet has the power and > open-endedness of python or javascript. I'm still pretty new to > python. PyCells http://pycells.pdxcb.net/ http://pycells.pdxcb.net/wiki/index.php?title=Basic_Tutorial > any ideas? i've been having some fun with VBA in excel > but I want something I can save as en exe and call my own creation, y'know? You can also do Excel automation using Python. http://www.markcarter.me.uk/computing/python/excel.html There are many packaging tools for Python. Py2exe is the most popular. Although in Excel's case, it would be difficult to make stand alone. -- http://mail.python.org/mailman/listinfo/python-list
Re: Will GPL Java eat into Python marketshare?
> Personally, I've never gotten jpype to work. Is it just me, or is it > a troublesome install? > > Harry George > PLM Engineering Architecture It works fine for me now. However, I do recall having an issue a while ago (most likely me, rather than JPype). -- http://mail.python.org/mailman/listinfo/python-list
Re: Fancy GUI with Python
> Hi all. I just downloaded and installed the new Office suite from MS > with their new 'ribbon' based UI. I think it's pretty cool and AFT* > for a new UI paradigm. I hope it sticks. > Anyway, I'm wondering how to implement a gui like this with Python. I haven't seen their new Office suit (apart form a few screenshots). Judging from the past, the code is probably statically linked to MS Office. Many of the previous iterations of MS Office did introduce their own look and feels, effects and widgets. Third party Windows developers soon followed suit reimplementing the widgets. Delphi community for example focuses a lot on UI and UI effects (Python community does not). VCL libraries can be compiled to ActiveX components and you should then be able to use them from Python, at least on Windows. Or maybe someone will make a .NET assembly and you will be able to drive it from IronPython or Python for .NET. If you are lucky, it may even be cross-platform via Mono. > So I'm not sure if this is a Python question, a xxx-Python question > (where xxx is the widget toolkit of choice), or a windows API type of > question. This is NOT a Python specific issue. It is a widget library and FFI (Foreign Function Interface) issue. If another language can get at the functionality, so can Python. -- http://mail.python.org/mailman/listinfo/python-list
Re: html 2 plain text
> i remember seeing this simple python function which would take raw html > and output the content (body?) of the page as plain text (no <..> tags > etc) http://www.aaronsw.com/2002/html2text/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Need C# Coding for MD5 Algorithm...
> I need C# code for Implementing MD5 Algorithm. So ask in a C# group. Python's is here http://docs.python.org/lib/module-md5.html > please Send... ITs URgent http://www.catb.org/~esr/faqs/smart-questions.html#urgent -- http://mail.python.org/mailman/listinfo/python-list
Re: How to access the content of notepad with Python?
> I have a software running on my computer that really looks like notepad > ( same interface, different name). I need to write a script that will > capture the content of this software --> the text written inside. > > Is it possible using win32 libs? any clue? http://www.openqa.org/pywinauto/ The example on their home page is in fact how to automate Notepad. I am sure you can work from there. -- http://mail.python.org/mailman/listinfo/python-list
Re: New to Python: Do we have the concept of Hash in Python?
A.M wrote: > "Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > A.M wrote: > > > >> This is my 1st day that I am seriously diving into Python and I have to > >> finish this application by the end of today. Maybe it wasn't a good idea > >> to choose the language that I don't know when I have to deliver my work > >> in such short time. > > > > are your boss aware of this ? > > > > > > > > > > are your boss aware of this ? > > In fact my boss is quite impressed with my progress so far. > > > > I am a little confused about the fact that you got frustrated with my posts > today. I am not asking for a big tutorial or > > deepest philosophy behind the concepts. The answer to this post could be > just the word "Dictionary" which is 10 key stroke ! > > Does this hurt? IRC is a better place to request 10 key stroke answers. And it is faster for you to get answers there too. Usenet is archived these days and it adds value to all of us that it is filled with discussions of questions that are more intellectual than those which can be looked up at a glance at the documentation. -- http://mail.python.org/mailman/listinfo/python-list
Re: in python , could I accomplish the purpose that "a=Console.read()" used in C?
Bruno Desthuilliers wrote: > python a écrit : > > in python , could I accomplish the purpose that "a=Console.read()" used > > in C? > > > There's nothing like "Console.read()" in ansi-C. > He probably got it mixed up with C# which ( almost - Console.Read() ) has that. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python or Ajax?
> I've been hearing a ot about AJAX lately. I may have to build a web > application in the near future, and I was curoius: > > How does a web application that uses Python compare with one that uses AJAX? > > I've done some basic web page design with HTML and CSS, but never any > web applications. I don't want to learn a new language if I can use > Python. Would AJAX offer me any significant advantages? AJAX is *NOT* a programming language. It is a certain way of building web applications. Any Python (or any other language) web framework may be used, though some (TurboGears / LivePage etc) have explicit support for it. I bit of googling does not hurt. -- http://mail.python.org/mailman/listinfo/python-list
Re: Combining The Best Of Python, Ruby, & Java??????
Tim Daneliuk wrote: > So it is claimed: > > > http://www.infoq.com/news/Scala--combing-the-best-of-Ruby-;jsessionid=CC7C8366455E67B04EE5864B7319F5EC > > Has anyone taken a look at this that can provide a meaningful contrast > with Python? I find the language very interesting but it is not like Python or Ruby at all. Feels a lot more like OCaml + Haskell for JVM with a more mainstream (Java) syntax. -- http://mail.python.org/mailman/listinfo/python-list
Re: Combining The Best Of Python, Ruby, & Java??????
> Ok, here's the Hello World example from the Scala website: > > object HelloWorld { > def main(args: Array[String]) = { > Console.println("Hello, world!") > } > } > > Opening and closing braces? > "def main(args: Array[String])"? > Console.println? > > About the only Pythonic thing I can see here is the "def" keyword. > Otherwise, it looks too much like Java - no, thanks! > > -- Paul Don't be too harsh on it though. It is a language built for the JVM/CLR. The author perhaps intended the library to be natural to the users of the respective SDKs regardless of its' aesthetics and it explicitly seems to provide a unified API for Java and .NET. Of course, that is nothing new. Many languages have interchangeable backends for these platforms these days but there seems to be a specific focus on that here. The syntax does resemble Java/C#, which is also important if you want buy in from the Java/C# crowd. But semantically it is a proper functional language. The features may not attract Python users who might prefer Boo/Jython/IronPython. But it does offer something to disillusioned Groovy users. But on the other hand, there are some neat features even for Python programmers. Tail recursion Pattern matching Currrying Macros Concurrency Native XML support Of course, you can get by without some of these in Python with workarounds, libraries or hacks. http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496691 http://www.python.org/dev/peps/pep-0309/ (in 2.5) http://logix.livelogix.com/ (offline) -- http://mail.python.org/mailman/listinfo/python-list
Re: Combining The Best Of Python, Ruby, & Java??????
Diez B. Roggisch wrote: > > But semantically it is a proper functional language. The features may > > not attract Python users who might prefer Boo/Jython/IronPython. But it > > does offer something to disillusioned Groovy users. > > Are they disillusioned? Just wondering. Nah! Just a poor passing attempt at humor. Groovy is a great language too. I should watch out. Maybe Groovy programmers have knives too :-). http://cardboard.nu/blog/2005_02_02/gosling_on_jvm_scripting.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Combining The Best Of Python, Ruby, & Java??????
Luis M. González wrote: > Diez B. Roggisch wrote: > > > But semantically it is a proper functional language. The features may > > > not attract Python users who might prefer Boo/Jython/IronPython. But it > > > does offer something to disillusioned Groovy users. > > > > Are they disillusioned? Just wondering. > > > > Diez > > Whay talking about disillutioned programmers? > These are tools, not religions... > I love python, and I like it more everyday. And with the advent of > Pypy, its future looks brighter than ever. > But I also find very interesting these new options that are coming up. > Although I'm not a professional programmer (not even a serious > aficionado), I love to be able to translate my python skills very > easily to .NET through Boo, for example. > I even find it more appealing than Ironpython, because it was created > from the ground up to take advantage of the CLR. > On the other hand, porting pure python to .NET is in many aspects like > trying to fit a square on a circle (I don't know if this sentence makes > sense in english...). > Because many of the design choices taken by GvR back in the early > nineties were surely conditioned by the platform he chose to write > python, which is the c language. > The good thing is that python is having a lot of influence in these new > languages. > As far as I could see, even C# 3.0 is showing up some pythonic traits. I did not realize the flame potential of that remark. Just to clarify, I have no criticism of any kind on Groovy. I mentioned Groovy since Scala, the original topic of the thread addresses the needs of the same group (a modern language with a Java friendly syntax). I am not a language bigot. Note that I am defending Scala, a new language, in this thread so far. I do not want this thread to break into a language war from my remark. I hope that Python gets some of the features listed in my above post in it's own unique Pythonic way eventually. The discussion perhaps is more constructive if we can see some good in Scala that is worth adopting. -- http://mail.python.org/mailman/listinfo/python-list
Re: code is data
Paddy wrote: > Anton Vredegoor wrote: > > With the inclusion of ElementTree (an XML-parser) in Python25 and recent > > developments concerning JSON (a very Pythonesque but somewhat limited > > XML notation scheme, let's call it statically typed XML) > > > > Your thoughts please. > > > > Anton > > Hi Anton. > If you mean this JSON: http://www.json.org/example.html > then I'd just point out that JSON isn't XML-like at all. In fact the > examples look like valid Python nested dictionaries. It is the same JSON. JSON is typically seen as a human friendly replacement for some of the functions that XML is otherwise used for, where the full blown XML spec is an overkill and JSON does not need complicated parsers in some common languages because it can express hierarchical data just like XML. -- http://mail.python.org/mailman/listinfo/python-list
Re: code is data
Anton Vredegoor wrote: > With the inclusion of ElementTree (an XML-parser) in Python25 and recent > developments concerning JSON (a very Pythonesque but somewhat limited > XML notation scheme, let's call it statically typed XML) Python seems to > have reached a stage where it now seems to be possible to completely > swallow lesser languages code, modify it, and spit out new source code > targeting the original language the code was written in, or even make a > translation to other languages. > > The idea is that we now have a fast parser (ElementTree) with a > reasonable 'API' and a data type (XML or JSON) that can be used as an > intermediate form to store parsing trees. Especially statically typed > little languages seem to be very swallow-able. Maybe I will be able to > reimplement GFABasic (my first love computer language, although not my > first relationship) someday, just for fun. > > Then there are things like cTypes (calling functions from native DLL's) > and PyPy (implementing Python in Python). > > All this taken together, to me it starts looking like we're now entering > a territory that traditionally was exclusively in the Lisp domain. > > Yes, Python had eval and exec for a long time already, and metatypes and > generators are having some strange unexplored possibilities too, but the > day will come soon (and at last when PyPy is reaching execution speeds > close to cPython) where Python will be able to swallow smaller > languages, and finally it will be able to swallow its own tail, like > Lisp but then more powerful (because of the widely used standard data > types and the code exchange between languages that that makes possible). > > Your thoughts please. I don't share your optimism at all. Most of the things you mentioned have existed for long. Just because some of them are now included in the standard library isn't going to change things drastically. Installing them earlier was never hard at all. People like to call everything with the lightest semblence, a DSL. That gives the feel that the language is more powerful. Ruby people do it all the time. Python cannot be called a DSL language until, creating them is a natural language feature (like Lisp). And that does not seem to be happening anytime soon. Boo for example allows you to write new constructs with it's AST library. It still cannot be called a DSL "language". People have however written various language interpreters (Scheme, Forth and yes, even Basic) in Python, just for kicks. Still does not make it a DSL language anymore than it makes C a DSL language. At present, the closest thing to writing a DSL in Python is Logix http://livelogix.net/logix/ Too bad though, the project is defunct and there has never been enough interest in it. Personally, I would like to see macros in Python (actually Logix succeeding is good enough). But I am no language designer and the community has no interest in it. When I absolutely need macros, I will go elsewhere. -- http://mail.python.org/mailman/listinfo/python-list
Re: Standard Yes / No Windows Dialog box creation
[EMAIL PROTECTED] wrote: > I found a way to create "Open File" or "Open Folder" windows dialog > boxes, but not to create an easier Yes / No dialog box... > Maybe someone has a solution for this? Assuming you are on MS Windows. import win32api, win32con win32api.MessageBox(0, "Question", "Title", win32con.MB_YESNO) -- http://mail.python.org/mailman/listinfo/python-list
Re: code is data
BJörn Lindqvist wrote: > > Personally, I would like to see macros in Python (actually Logix > > succeeding is good enough). But I am no language designer and the > > community has no interest in it. When I absolutely need macros, I will > > go elsewhere. > > One must wonder, when is that? When do you absolutely need macros? Whenever there is significant boiler plate code that functions and classes cannot eliminate alone. Whenever there is a more elegant way to express your code. Python 2.5 introduced conditional expressions and with statement. With macros, one would not have to wait for the language team to implement them. More so for features which only a small part of the community has an interest in. I *like* 1..5 (ada, ruby) instead of range(5). If I had macros, I would have done it myself for *my* code. I would like special behaviour code blocks in my programs, for say DBC (I am aware of the work arounds). -- http://mail.python.org/mailman/listinfo/python-list
Re: code is data
Paddy wrote: > Ravi Teja wrote: > > BJörn Lindqvist wrote: > > > > Personally, I would like to see macros in Python (actually Logix > > > > succeeding is good enough). But I am no language designer and the > > > > community has no interest in it. When I absolutely need macros, I will > > > > go elsewhere. > > > > > > One must wonder, when is that? When do you absolutely need macros? > > > > Whenever there is significant boiler plate code that functions and > > classes cannot eliminate alone. > > Whenever there is a more elegant way to express your code. > > > > Me, I am torn. I should now better. I have listened to the arguments > against Macros in Python and the ones that struck home were the > argument for maintainability: > Without macros, Python is Python. Statements do what you expect. Yes! I heard those arguments too. And I am not convinced. Static language programmer: Lack of static typing removes the necessary safeguards. The code is more error prone. Objects have behavior that is not obvious. Dynamic language programmer: Really? I don't seem to have any more bugs than in my statically typed code. And my code is compact and reads better. I don't want to go back. No to macros proponent: Macros introduce a lot of potential for abuse. Code will be worse to read than Perl. Macros proponent: Really? We have been doing macros for decades. We all think our code is better for macros, not worse. We are not going back. I just don't get it. Don't we often invoke the "We are all adults here" argument. Writing a macro is not as simple as writing a function. Sort of like metaclasses. Many will stay off them. Those that really need them will walk that extra mile. Don't we all believe that "Simple should be possible. Complex should be doable" > And the argument against DSLs altogether: > Make Python your DSL! If you design your own DSL before long you start > to embellish it with more statements or data types and before long it > becomes complex. If you used Python from the beginning then you would > have a community for support. Python has a low cognitive overhead. But it not a DSL by definition. No language can be. The idea is that when the domain changes, a DSL should be driven by the new domain as warranted. In other words, driven "by the problem, not the tool". I don't want "a DSL". I want a language that allows me to make "my DSL" based on it. That means I don't loose the community connection. I can still use all the rich libraries in my DSL. I like Python for its indentation syntax, sensible semantics and readability. I invested a lot of time in Python. After much language hopping, I settled with Python. I like the community and the code base available for it. The libraries just seem to be designed at the right level of abstraction for me (as opposed to say, Java). When I need to do something, I know where to go. But all this ties me to the language tightly that I cannot change. > I know the arguments, but every once in a while I think if only I could > craft my own ??? statement or My thoughts exactly. Web frameworks, which seem to be the rage now in Python community could have benefited tremendously from Macro capabilities since they have a lot of boiler plate. -- http://mail.python.org/mailman/listinfo/python-list
Re: code is data
Fredrik Lundh wrote: > Ravi Teja wrote: > > > Web frameworks, which seem to be the rage now in Python community could > > have benefited tremendously from Macro capabilities since they have a > > lot of boiler plate. > > they do? methinks you haven't done much web programming lately... > > You blogged on Django. Let's use that. Don't you think model creation in Django can be represented better, given that it is done often enough? Let's take an example from the official tutorial from http://www.djangoproject.com/documentation/tutorial1/#creating-models class Poll(models.Model): question = models.CharField(maxlength=200) pub_date = models.DateTimeField('date published') class Choice(models.Model): poll = models.ForeignKey(Poll) choice = models.CharField(maxlength=200) votes = models.IntegerField() I don't use Django and I made this up quickly, so please don't pick on subtleties. @Poll: question: char length 200 pub_date('date published'): date @Choice: poll -> Poll choice: char length 200 votes: int The following is my rationale. Annoted variables, symbols and code layout visually cue more efficiently to the object nature than do explicit text definitions. Of course, this is only sensible when there aren't too many of any of those. In that case, the cognitive cost of notation outweighs the representational cost of text. Representational minimalism is troublesome in general code (ala Perl), but not so in a DSL where the context is constrained. I would also like to symbolize field types since they occur so commonly in a definition file and only a few of them are commonly used. I admit though that I find the code below a bit visually jarring and I might use something else. But it serves to illustrate the point. I chose the respective symbols based on their colloquial use and association with the field types. @Poll: $question: length 200 %pub_date('date published') @Choice: poll -> Poll $choice: length 200 #votes Since you are on thread and are a prominent and involved member of the Python community, I would like it if you (or any such other) can provide feedback on the rest of my previous post rather than be dismissive by just a small portion of it. Perhaps, that will give me some insight how these language design decisions are rationally made (I am not strictly a programmer by profession, much less a language designer). -- http://mail.python.org/mailman/listinfo/python-list
Re: code is data
BJörn Lindqvist wrote: > > > > community has no interest in it. When I absolutely need macros, I will > > > > go elsewhere. > > I *like* 1..5 (ada, ruby) instead of range(5). If I had macros, I would > > have done it myself for *my* code. > I think this example more is a symptom of a childish need to get > things your way than of a deficiency in Python. I thought I had enough asterisks in there to indicate that it is a preference that I will not be defending on rational grounds. I had a better argument before it in the same post. But you had to choose only the trivial one to dismiss me as childish. Didn't you? :-) > BTW, range(5) = 0..4 in Ada and Ruby. My bad. I usually write range(1, 5 + 1) to get 1..5. I could write range(1, 6). But I would like to see the upper bound explicitly. Of course, I could write a function to wrap that up. > You said "when I absolutely need macros" but none of your examples > demonstrate any "absolute need." I can't see your point. Did you miss the word - *WHEN*? I don't need them absolutely now. And I know, that I won't get them here. And just so you don't misinterpret, I don't call that a "deficiency". Just a mismatch between the personal and the community mindset. BTW, the recent language changes - decorators, conditional expressions and with statements are not absolute either. That did not stop them from being welcome additions. -- http://mail.python.org/mailman/listinfo/python-list
Re: code is data
Kay Schluehr wrote: > Ravi Teja wrote: > > > People have however written various language interpreters (Scheme, > > Forth and yes, even Basic) in Python, just for kicks. Still does not > > make it a DSL language anymore than it makes C a DSL language. > > > > At present, the closest thing to writing a DSL in Python is Logix > > http://livelogix.net/logix/ > > Too bad though, the project is defunct and there has never been enough > > interest in it. > > You might be interested in EasyExtend: > > http://www.fiber-space.de/EasyExtend/doc/EE.html Your framework does look very interesting and might just be what I am looking for. Will give it a try. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: code is data
> Or... maybe to be more specific, the hard work later on goes into > *code*. If you are enhancing your model, you do so with methods on the > model classes, and those methods don't effect the DSL, they are just > "code". You create some raw XML in the beginning, but quickly it's > just a matter of gluing those pieces together, using functions instead > of DSLs, and that's just "code". > That doesn't look that much better. How do you create it > programmatically? I know how to pass a variable to > CharField(maxlength=200); can I pass a variable to "char length 200" > just as easily? Can I use **kw? Can I read it from a CSV file and > construct the class that way? Maybe, but only by recreating all the > native patterns that I can infer easily looking at the Django class. I am looking at it from the cognitive perspective. You are looking at it from the compiler perspective. I think you are talking about full blown DSLs like SQL which try to be self contained for a given domain. The ones I am referring are only thin layers on Python. > Words are great. Python is light on symbols, and that is good. Agreed. When I came to Python from Perl, I loved the clean syntax. Scalars, arrays, hashes occur too frequently in Perl code that using symbols to denote them causes more noise than cognitive assistance. On the other hand, using symbols to denote an occational special construct is helpful (as in decorators). > Even the Lisps stick to an incredibly homogenous syntax (far more > homogeneous than Python) to make macros feel familiar. Yes! The parser friendly, "everything is a list" syntax does help. I did consider that to be an essential feature to enable dynamic macros. However I changed my mind when I saw Logix macro syntax. > Constrained context is a step backward! How do you add methods? How > do you do looping? How do you write *code*? If you aren't going to > allow those things, then just make a parser and build the structure > from the file, and make it a DSL implemented entirely external to > Python. That's completely okay, though in my experience it's not very > satisfying for something like a model definition (see MiddleKit for an > example of an ORM that doesn't use Python code). I agree that constrained context is a step back in terms flexibility. But it is a strategic step backwards, in this case to trade for representational benefits. The extent of constraints is a judgement call. And proof of utility can only be emperical. However I think that you are seeing my sample differently than I meant it. I did not mean to create a special syntax file that would be parsed as a text file such that it would loose all the benefits of Python. It is just a thin layer over Python code for specific representational benefits. Kay Schluehr does a good job of identifying it as such in his reply. -- http://mail.python.org/mailman/listinfo/python-list
Re: code is data
> I don't think that distinction is very meaningful. As a programmer I > have to understand both. > I understand the Python compiler well, and it gives me reasonably good > feedback when I > get things wrong, and it has a lot of flexibility along several > orthogonal lines. > We're talking about programming languages, so it's useless to consider > a cognitive perspective without considering the compiler perspective. As some one who has followed your excellent articles, posts and tools over the last many years, I don't doubt your expertise at all. I admit I am not be entirely looking at this as a programmer. I am working in informatics for the last few years. At least in this domain, it is useful to seperate the perspectives. Sort of like designing a functional language based primarily on mathematical abstractions rather than imperative realities. Yes! Once the implementation is underway, the practical realities are unavoidable but they interfere in thinking, otherwise. > I understand you, but it's very unclear to me how you can make a thin > layer that's not horribly leaky or stunted. In my experience one or > both are likely in DSLs, and the result is horrible and only useful as > a toy. I am not making this up out of thin air. There is already an implementation, Logix, which allows you make thin layer DSLs on top of itself (which in turn sits on top of Python). It did not fly but I could not technically fault it (except maybe that it is not very optimized at the moment). Maybe with your better understanding of language implementations, you can. > I understood the distinction you were making. But you were also > speaking generally about generally programmable syntax, and I don't > think that's a good idea, and it's very unclear how that mixes with > Python. You can always do: > > model = make_model(""" > my funny syntax > """) > > And you actually get something that can be a close peer to normal > Python code. But if you are talking about Python and some novel syntax > interleaved, then the details seem to matter a lot, because the > implementation is substantial and potentially invasive. NO! I have a feeling that you are interpreting me as a language radical. I do not think that Python syntax should have too many novelties. Currently Python feels a cohesive whole. A well designed entity rather than something that evolved by accretion of features like Perl. With active attempts to prune inconsistencies for that end (Python 3000). And I value all that. But Logix does not add ANY new syntactic constructs to Python. There is a special import function that imports a macro supporting Python language variant module where one can create special syntactic constructs. I am quite satisfied with the macro capabilities of Logix. But I am just grumbling that the Python community does not find macros interesting. But without enough users, it simply dies away. -- http://mail.python.org/mailman/listinfo/python-list
Re: Import Issue
[EMAIL PROTECTED] wrote: > What is the difference between >import string > and >from string import * Here is an explanation. http://effbot.org/zone/import-confusion.htm -- http://mail.python.org/mailman/listinfo/python-list
Re: what do you guys prefer for ajax?
a wrote: > what do you guys prefer for ajax? > dojo > mochikit > prototype > or somehting else/ I am using OpenLaszlo for a project with a Karrigell (Python) ReST backend. Now strictly speaking, this is not AJAX at the moment. It uses Flash but has the same "asynchronous updates from the server" model. I am waiting for their DHTML engine to mature to switch to it (they just released a preview). The DHTML engine is AJAX and is based on Dojo toolkit. Pro:. 1.) Declarative UI development. 2.) Good look and feel for free. 3.) Comprehensive API for data binding. 4.) Excellent documentation. Cons: 1.) Only Flash available now. You might want to take a look at TurboGears 1.0 preview as well. They have made quite a bit of progress integrating MochiKit. -- http://mail.python.org/mailman/listinfo/python-list
Re: code is data
I missed this reply earlier. Fredrik Lundh wrote: > there might be cognitive theories that argue that the length of the > symbols used to describe something is more important than the symbols > you use and how they can be "chunked" by the brain Expert communication is known to work differently. For example, take a doctor's note. It's minimalist representation and domain specific notational standardizations are absolute gibberish for a reader without the knowledge of medicine (or more specifically, the sub-specialty) and the context of the patient. But it is very efficient for the audience it is intended for. Now, the hand writing - that's a wholly different story :-). BTW, I am studying clinical information representations. This discussion was interesting to me because I am trying to see programming language representation as a better discussed and more structured microcosm of the relatively fuzzy domain I am studying. Of course, there are many important differences and I may be drawing the parallels liberally at this point but it gives me an interesting perspective. -- http://mail.python.org/mailman/listinfo/python-list
Re: beautifulsoup .vs tidy
bruce wrote: > hi... > > never used perl, but i have an issue trying to resolve some html that > appears to be "dirty/malformed" regarding the overall structure. in > researching validators, i came across the beautifulsoup app and wanted to > know if anybody could give me pros/cons of the app as it relates to any of > the other validation apps... > > the issue i'm facing involves parsing some websites, so i'm trying to > extract information based on the DOM/XPath functions.. i'm using perl to > handle the extraction 1.) XPath is not a good idea at all with "malformed" HTML or perhaps web pages in general. 2.) BeautifulSoup is not a validator but works well with bad HTML. Also look at Mechanize and ClientForm. 3.) XMLStarlet is a good XML validator (http://xmlstar.sourceforge.net/). It's not Python but you don't need to care about the language it is written in. 4.) For a simple HTML validator, Just use http://validator.w3.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: I have 100 servers which need a new backup server added to a text file, and then the backup agent restarted.
gavino wrote: > This seems easy but I have been asking tcl and python IRC chat all day > and no one gave an answer. > I have 100 servers which need a new backup server added to a text file, > and then the backup agent restarted. > If I have a list of the servers, all with same root password, and the > connection is ssh. > How do I connect to the server, cat the line to the config file, stop > adn start the agent, and then do same to next server in list and > iterate through the 100 servers. > What script would allow this? Try pxssh from pexpect. Look at the sample in the page. http://pexpect.sourceforge.net/pxssh.html It will allow you to automate ssh interactions. -- http://mail.python.org/mailman/listinfo/python-list
Re: I have 100 servers which need a new backup server added to a text file, and then the backup agent restarted.
LittlePython wrote: > Does this require a ssh client or server? > > I use authpf to open up my PF firewall for internet use. Generally I just > open up putty and make a connection to the FW ( which open the ports) and > minize it till I am done. When I close putty authpf losses the ssh session > heartbeat and will then instruct the FW to close the ports. I would love to > write a simple client to do this form me instead of using putty. Do you > think these mods would work for me on a windows platform? > > Thx Pexpect needs a POSIX system. However, you can use Cygwin. >From the website, "Pexpect does not currently work on the standard Windows Python (see the pty requirement); however, it seems to work fine using Cygwin." -- http://mail.python.org/mailman/listinfo/python-list
Re: building/installing python libs/modules...
> i've got the python app: > http://www.boddie.org.uk/python/downloads/libxml2dom-0.3.3.tar.gz > > and i've downloaded it, an untarred it... > i have the dir structure, but i don't know what needs to be done now!!! i > have a setup.py. does it get run? > > the Readme file didn't tell me how to build the app The setup.py is a distutils installer. The usual drill in that case is to simply type "python setup.py install". If the module is registered in PyPi (which this one is), you can just type "easy_install libxml2dom" (after easy_install is setup) and you will not even need to download and extract. In this case, your module is a native wrapper. So you will need the libraries that it provides a wrapper for, installed. In this case (libxml2, libxml2dom). You will also need a C compiler. All this can be trivial on a unix based platform. However, if you are new and on Windows, this can be a hassle since you will have to manually setup your C compiler and the dependencies. Try to find a binary installer for native Python modules in MS Windows whenever you can. Here is a click and go installer built for Windows that I found from Google. http://users.skynet.be/sbi/libxml-python/binaries/libxml2-python-2.6.22.win32-py2.4.exe -- http://mail.python.org/mailman/listinfo/python-list