Re: Independence of programs!
blade8472 wrote: > > Hey all, hope all is fine, I have a question; I am new in python > programming, I write the programs to a text doc then I run them with > the interpreter, so I wanna know whether I can save the programs as > exe so that they can be run independently on other PCs without the > python interpreter. > hope you help me, thanks alot! If you are under Microsoft Windows (which I guess, according your question), you may use py2exe ( http://starship.python.net/crew/theller/py2exe/ ). It will do all the required stuff for you to have a standalone executable. David -- http://mail.python.org/mailman/listinfo/python-list
Redirecting stdout/err under win32 platform
Hi everybody, let me explain by problem: I am working on an application which consists in a C++ dll (numeric computations) and a Python IHM (Python/Tk), which must run under Linux and win32. My problem is the C++ lib does write stuffs on its stdout, and I would like to print those messages in a Tk frame. When I run the computation, it has it's own thread. So my question is : how van I redirect the dll's stdout to something I can retrieve in Python (pipe, socket,...)? I can do it easily under Linux. I made tests with a socket which just works fine. In the threaded function (that will do the heavy computation), I write: import os, sys from socket import * s=socket(AF_UNIX, SOCK_STREAM) s.connect(...) os.dup2(sys.__stdout__.fileno(), s.fileno()) very_intensive_function(many_parameters) s.close() That's OK under Linux, but does not work under win32 (even if I use an INET localhost socket), cause I cannot do the os.dup2 trick (Windows does not want to consider a socket as a file! What a shity system!). So my question is : is there a simple solution ? I have tested different solutions. I am trying hacks with pipes created with the win32api. But I have not yet managed this simple operation. Note that I have no access to the dll source code, so I cannot modify it so it uses a named pipe (for example) as message output pipe instead os stdout... Thanks, David -- http://mail.python.org/mailman/listinfo/python-list
Re: Redirecting stdout/err under win32 platform
Alan, I did search Google for this problem (not enough, thou). In fact, I found some kind of solution (by myself, not that much on Google), but it is not really satisfactory. I have used win32 pipes to do so (win32api.CreatePipe). I can redirect stdout/stderr to it from my python code (even redirecting the stdout/stderr from my C lib). But I still have a problem with this solution (well, 2): - it is *much* more complicated than any solution available on Unix like systems (not really a problem, but), - it not synchronous at all. And I'd like it to be so (or almost so). David yaipa wrote: > David, > > Googling comp.lang.python /w this string "stderr win32" yielded 109 > results. > So I think if you poke around a bit you will find your answer in the > archives. > > Sorry for no direct help tonight... > > Cheers, > > --Alan > David Douard wrote: >> Hi everybody, >> >> let me explain by problem: >> I am working on an application which consists in a C++ dll (numeric >> computations) and a Python IHM (Python/Tk), which must run under > Linux and >> win32. My problem is the C++ lib does write stuffs on its stdout, and > I >> would like to print those messages in a Tk frame. When I run the >> computation, it has it's own thread. >> >> So my question is : how van I redirect the dll's stdout to something > I can >> retrieve in Python (pipe, socket,...)? >> >> I can do it easily under Linux. I made tests with a socket which just > works >> fine. In the threaded function (that will do the heavy computation), > I >> write: >> >> import os, sys >> from socket import * >> s=socket(AF_UNIX, SOCK_STREAM) >> s.connect(...) >> os.dup2(sys.__stdout__.fileno(), s.fileno()) >> very_intensive_function(many_parameters) >> s.close() >> >> That's OK under Linux, but does not work under win32 (even if I use > an INET >> localhost socket), cause I cannot do the os.dup2 trick (Windows does > not >> want to consider a socket as a file! What a shity system!). >> >> So my question is : is there a simple solution ? I have tested > different >> solutions. I am trying hacks with pipes created with the win32api. > But I >> have not yet managed this simple operation. >> >> Note that I have no access to the dll source code, so I cannot modify > it so >> it uses a named pipe (for example) as message output pipe instead os >> stdout... >> >> Thanks, >> David -- http://mail.python.org/mailman/listinfo/python-list
Re: continuous plotting with Tkinter
Martin Blume wrote: > I have a number-crunching application that spits out > a lot of numbers. Now I'd like to pipe this into a python > app and plot them using Tkinter, such as: > $ number_cruncher | myplot.py > But with Tkinter once I call Tkinter's mainloop() I > give up my control of the app and I can't continue to > read in data from stdin. Or can I? If so, how? > > Regards > Martin Maybe the simpler is to run the Tk mainloop in a separate thread. You may have a look a candygram which gives a very simple to use multi-thread semantics (ala Haskell) and is simpler to use than the threading module. -- http://mail.python.org/mailman/listinfo/python-list
Re: Basic file operation questions
Marcel van den Dungen wrote: > alex wrote: >> Hi, >> >> I am a beginner with python and here is my first question: >> How can I read the contents of a file using a loop or something? I open >> the file with file=open(filename, 'r') and what to do then? Can I use >> something like >> >> for xxx in file: >> >> >> >> Thanks for help >> Alex >> > take a look at this: > http://www.devshed.com/c/a/Python/File-Management-in-Python/ > > HTH, > -- Marcel Or even have a look at the excellent Gnosis book on the subject (and very much more further, but...): http://gnosis.cx/TPiP/ which is freely available in text format. David -- http://mail.python.org/mailman/listinfo/python-list
Re: Basic file operation questions
David Douard wrote: > Marcel van den Dungen wrote: > >> alex wrote: >>> Hi, >>> >>> I am a beginner with python and here is my first question: >>> How can I read the contents of a file using a loop or something? I open >>> the file with file=open(filename, 'r') and what to do then? Can I use >>> something like >>> >>> for xxx in file: >>> >>> >>> >>> Thanks for help >>> Alex >>> >> take a look at this: >> http://www.devshed.com/c/a/Python/File-Management-in-Python/ >> >> HTH, >> -- Marcel > > Or even have a look at the excellent Gnosis book on the subject (and very > much more further, but...): > http://gnosis.cx/TPiP/ which is freely available in text format. > > David Just to tell (it's not clear at all in my message): the author of the book and creator of Gnosis Software is David Mertz, and the book is published by Addison Wesley. Sorry David -- http://mail.python.org/mailman/listinfo/python-list
