pipe related question
Is there any way to have one program run another arbitrary program with input from stdin and display the output as if you had run it in a shell (i.e., you'd see some of the output followed by the input they typed in and then a newline because they pressed return followed by subsequent output, etc.). I can't use readline with the pipe because I don't know how much output the arbitrary program has before it calls an input statement. I've googled and understand that calling read() will deadlock when the program is waiting for input. When I first write all the input to the input pipe and then call read on the output pipe it works just the same as if I had run the program as: program < input_file What I'd like to see is the input intermixed with the output as if the user had typed it in. Thanks, Dave -- http://mail.python.org/mailman/listinfo/python-list
OT Re: getaddrinfo not found on SCO OpenServer 5.0.5
On Jul 21, 2006, at 4:20 PM, Steve M wrote: > In case you haven't heard Microsoft is suing SCO for stealing his > Internet concepts and letters and numbers, so you should probably just > ditch OpenServer and get Debian like all the smart people have done. > > I guess the quality of SCO software has declined over the last > forty or > fifty years and they had to have David Boies compile libsocket and > that > is probably why this broken symbol problem is happenig. > > I'm sorry if you cannot switch from the SCO platform, in which case > this message may not be very helpful. Have a nice day! This is way off-topic, but it's SCO that is suing IBM and IBM countersuing SCO. It appears that Microsoft was helping bankroll SCO's lawsuit. If you want to see how it's going, look at a graph of the SCOX (the ticker symbol) stock price since 2003 (paying close attention to the more recent price as the judge has started ruling on discovery issues). It was in 2003 when they started claiming everyone using Linux owed them money and they sued IBM for billions of dollars. Also see groklaw.net if you really want to know more about it. In the interest of full disclosure, I made money shorting SCOX stock from mid 2003 to mid 2004 (borrowed and sold at $11, bought back at $5). Dave -- http://mail.python.org/mailman/listinfo/python-list
Re: fast pythonic algorithm question
On Aug 1, 2006, at 11:13 AM, Diez B. Roggisch wrote: > Guyon Morée wrote: > >> Memory is no problem. It just needs to be as fast as possible, if >> that's what this is, fine. >> >> If not, I'd like to find out what is :) > > I'd say it is as fast as it can get - using hashing for lookups is O > (n) in I know you meant O(1) for hash lookups, but just in case anyone is confused, I figured I'd correct this. > most cases, where bisection or other order-based lookups have O(log n) > > Additionally, dict lookups are fully written in C. > > Diez Dave -- http://mail.python.org/mailman/listinfo/python-list
Re: Python taught in schools?
> > MilkmanDan wrote: >> I'll be a college freshman this fall, attending Florida Institute of >> Tech studying electrical engineering. >> >> I was considering taking some classes in programming and computer >> science, and I happened to notice that everything taught is using C >> ++. >> After further research, it seems to me that C++ seems to be the >> dominating language in universities. Actually, I think Java is the most commonly used language in the CS1, although C++ may be more popular at engineering institutions. >> >> By comparison, our local community college teaches a few classes >> in VB, >> Java, Javascript, C++, and for some reason, PASCAL. >> >> I'm certianly not against any of this, but out of curiousity does >> anyone know of a school that teaches Python? See the following for a list compiled from responses on the python- edu list. http://studypack.com/comp/mod/glossary/view.php?id=2835 Dave -- http://mail.python.org/mailman/listinfo/python-list
Re: New editions of several Python books.
On Feb 9, 2006, at 3:59 PM, James Stroud wrote: > Magnus Lycka wrote: >> Programming Python, 3rd edition >> by Mark Lutz (Paperback - July 2006) >> >> Never a favourite of mine really, but a popular book... > > This one is like broccoli. Its good for you but it doesn't have > much flavor. > -- > http://mail.python.org/mailman/listinfo/python-list I found the Learning Python book (that Lutz is a co-author of) a much better book for someone who knows another language and wants to learn Python. The Programming Python has lots of examples, but I found it difficult to "look things up". The three books I would recommend for someone (who already knows another language) wanting to learn Python are: Learning Python Python Essential Reference Python Cookbook Dave -- http://mail.python.org/mailman/listinfo/python-list
Re: GladeGen and initializing widgets at startup
On May 6, 2006, at 4:39 PM, Aengys wrote: > Hi all, > > Being struck by article 7421 of the linux journal > (http://www.linuxjournal.com/article/7421), I'll tried to give it a > go. > Mainly because I have done some experiments with Glade and found that > it is really easy to create good looking GUIs. On the other end, there > is the GladeGen tool which helps you in building a skeleton in Python > such that you only have to code the events. But being a newbie with > Python as well as Glade I'm heavily dependent on documentation (mainly > online a big part being usenet). There I found that almost nobody > seems to use it, or they don't have any problems with it. In this > group > there is only thread that has a reference to it! > > So my questions: > > Does anybody use GladeGen? If not, why? > > For those that do use it, where do I write the code which has to be > executed when a window loads? The thing is pretty basic here. I > have a > window with a treeview, and I simply want that treeview filled up when > opening the window. > > Hoping for some echos... > > Aengys > I'm the author of it - I got a number (20-30 I think) of responses from people using it and a few quick questions. I emailed the gnome- python maintainer to see if they were interested in including it or taking it over, but never heard back. If anyone wants to take it over and extend it, you're welcome to. I believe Linux Journal maintained copyright ownership for a few months after the publication but then it reverts back to the author so I'll happily release it under the GPL for anyone to extend. To answer your question, you can put your code in the init method after the call to: GladeWindow.__init__ or you can override the GladeWindow's show method in your class if you want it to be called every time the window is shown. I often wrote a method named "populate" to file in data in widgets and then called it from the show method. Dave -- http://mail.python.org/mailman/listinfo/python-list
Re: GladeGen and initializing widgets at startup
On May 7, 2006, at 4:24 AM, Aengys wrote: > Thank you for your reply! > > I finally managed to do what I wanted. Maybe a little side-remark > here. > In the article you have said that all changes to the init-method are > lost once you regenerate the file. I have tried it, and indeed all my > changes were lost (which I had backed up before). So I've created a > method which do the initialization and I call this method from the > init-method. Maybe it would be a nice extention to include such a > method by default; a method you can fill with all the code that needs > to be done when initializing the window I'm not yet so familiar > with the whole process, but I might have a look at it in the future. > I'll keep you updated on that if it happens. > It's been a while since I've looked at it or used it (haven't been doing an GUI programming recently). I should have said to put your code in the __init__ method after the call to init since the init method is regenerated each time. > Regarding the extension of the show method: how do I do that? And what > benefit does it have to the solution mentioned above? You mentioned you were new to Python - you really need to learn more (specifically about inheritance) before you can fully understand this. The GladeWindow provides a show method but you can write your own show method that would get called instead of it. If you want the code to just be called once, using the __init__ method is appropriate but if your window is repeatedly shown/hidden and you want the code executed each time the window is shown. Dave -- http://mail.python.org/mailman/listinfo/python-list
Re: hyperthreading locks up sleeping threads
On May 10, 2006, at 5:39 PM, [EMAIL PROTECTED] wrote: > Grant > >> You might want to run some memory tests. > > We have multiple identical boxes and they all have the same problem. > > Olaf They might all have flaky memory - I would follow the other poster's advice and run memtest86 on them. Dave -- http://mail.python.org/mailman/listinfo/python-list
Re: Threads
On May 11, 2006, at 8:02 PM, placid wrote: > > Carl J. Van Arsdall wrote: >> placid wrote: >>> Hi all, >>> >>> In Python, Threads cannot be paused, i remember reading this >>> somewhere, >>> so is there a way around this ? >>> >> >> When you say paused do you mean paused by an external source or >> paused >> by a call internal to the thread? There are plenty of >> synchronization >> constructs for making threads wait: Check out Events and Conditions > > I have a thread that has a job Queue, it continuosly polls this queue > to see if there are any jobs for it, what i really wont to be able to > do is, when the queue is empty, i want the thread to pause (or more > technical, i want the thread to block) until the queue gets populated > again. Is this possible ? > > The previous poster answered your question - you want to use a condition variable. http://docs.python.org/lib/condition-objects.html Dave -- http://mail.python.org/mailman/listinfo/python-list
Re: how relevant is C today?
On Apr 8, 2006, at 6:35 PM, Jorge Godoy wrote: > Mirco Wahab <[EMAIL PROTECTED]> writes: > >> "The Dice" (find tech jobs) has offerings >> (last 7 days, U.S. + unrestricted) for: >> *SQL 14,322 >> C/C++11,968 >> Java 10,143 >> ... >> Perl 3,332 >> PHP 730 >> *Python* 503 >> Fortran 119 >> Ruby108 >> open*gl 66 >> >> That is what the industry looks for. >> You understand the ratios? > > Of course! You need 23 C/C++ people to do the job of one > Pythoneer ;-) > > -- > Jorge Godoy <[EMAIL PROTECTED]> +1 QOTW Dave -- http://mail.python.org/mailman/listinfo/python-list
Re: ping
On Apr 14, 2006, at 6:30 PM, david brochu jr wrote: > I am trying to ping websites and output the results to a txt file: > > import os > > file = open("c:\python24\scripts\ip.txt") > redirect = open("c:\python24\scripts\log.txt","a") > > for x in file: > ping = "ping " + x > print >> redirect, os.system(ping) > > > but the results seen in the log.txt file are: > > 0 > 0 > 0 > 0 > 0 > 0 > 0 > 0 > > > What am i doing wrong?? How do I fix this so I can see the ping > statistics inside the log.txt file? os.system does not return the output of the command. Look at os.popen. Dave -- http://mail.python.org/mailman/listinfo/python-list
Re: ping
On Apr 14, 2006, at 8:04 PM, david brochu jr wrote: > Thanks, > > Unfortunately substituting os.system with os.popen results in the > output being: > > ', mode 'r' at 0x009C4650> > ', mode 'r' at 0x009C4650> > ', mode 'r' at 0x009C4650> > ', mode 'r' at 0x009C4650> > > instead of giving me the ping stats "pinging etc etc, packets sent > 4 recienved 4 etc) > > Any idea around this? os.popen gives you a file-like object that you can then read. >>> import os >>> f = os.popen('ping -c 5 www.google.com') >>> text = f.read() >>> print text PING www.l.google.com (64.233.167.147): 56 data bytes 64 bytes from 64.233.167.147: icmp_seq=0 ttl=241 time=20.855 ms 64 bytes from 64.233.167.147: icmp_seq=1 ttl=241 time=26.262 ms 64 bytes from 64.233.167.147: icmp_seq=2 ttl=241 time=22.300 ms 64 bytes from 64.233.167.147: icmp_seq=3 ttl=241 time=23.957 ms 64 bytes from 64.233.167.147: icmp_seq=4 ttl=241 time=22.056 ms --- www.l.google.com ping statistics --- 5 packets transmitted, 5 packets received, 0% packet loss round-trip min/avg/max/stddev = 20.855/23.086/26.262/1.871 ms >>> Dave -- http://mail.python.org/mailman/listinfo/python-list