Re: Popen3 on Windows
Jeffrey Barish wrote:
> I have an application that has been working fine on Linux, but now I need to
> port it to Windows XP. The program uses Popen3 to run another program. I
> use Popen3 so that I can access the pid attribute, which I use to kill the
> auxiliary program when necessary. Popen3 does not exist on Windows. I see
> os.popen2 and os.popen3, but they provide only file objects for stdin,
> stdout, and stderr so I don't see a way to kill the auxiliary program that
> I start. Is there a way to do this on Windows?
> --
> Jeffrey Barish
>>>import subprocess
>>>x = subprocess.Popen('nc -l 2')
>>>x.pid
2783
>>>subprocess.Popen('taskkill %s' % x.pid)
>>> x.poll()
1
--
http://mail.python.org/mailman/listinfo/python-list
Re: fetching a POST webpage...
bruce wrote:
> hi...
>
> i have the basic code to fetcha url/web page. however, i'm trying to fetch a
> page that uses a FORM/POST. has anyone done this, i've tried a few times
> without success.
>
> i've analyzed the data stream using Firefox/Livehttpheaders to get the HTTP
> stream.. but i'm doing something wrong, and can't quite see what the
> err/issue is...
>
> if you've done this kind of thing, and you have some thoughts, let me know.
> i can send you the output of the livehttpheaders app, and the test code that
> i have...
>
> thanks..
>
> -bruce
If you read the page and parse the form or already know the values you
need to POST this may help.
>From http://www.python.org/doc/current/lib/httplib-examples.html
Here is an example session that shows how to "POST" requests:
>>> import httplib, urllib
>>> params = urllib.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0})
>>> headers = {"Content-type": "application/x-www-form-urlencoded",
..."Accept": "text/plain"}
>>> conn = httplib.HTTPConnection("musi-cal.mojam.com:80")
>>> conn.request("POST", "/cgi-bin/query", params, headers)
>>> response = conn.getresponse()
>>> print response.status, response.reason
200 OK
>>> data = response.read()
>>> conn.close()
--
http://mail.python.org/mailman/listinfo/python-list
Re: SMTPlib Sender Refused?
On Jun 2, 1:20 pm, erikcw <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm trying to send an email message with python, and I'm getting this
> error:
>
> Traceback (most recent call last):
> File "wa.py", line 430, in ?
> main()
> File "wa.py", line 425, in main
> smtp.sendmail(fromaddr, to, msg.encode('utf-8'))
> File "/usr/local/lib/python2.4/smtplib.py", line 680, in sendmail
> raise SMTPSenderRefused(code, resp, from_addr)
> smtplib.SMTPSenderRefused: (503, 'sender already given',
> '[EMAIL PROTECTED]')
>
> What is causing this?
>
> Thanks!
> Erik
This error is given when the MAIL command has already been sent.
Usually this is indicative of some command failing (maybe invalid rcpt
to:??) and retrying without sending the RSET command.
Try connecting manually and see what you get.
~r
--
http://mail.python.org/mailman/listinfo/python-list
Re: Trouble killing a process on windows
On Jun 2, 12:27 pm, Thomas Nelson <[EMAIL PROTECTED]> wrote: > Hi, I'd like to start a program, run it for a while, then terminate > it. I can do this on linux, but I'm new to working with windows. > Here's my script: > > from subprocess import Popen > from time import sleep > import win32api > war3game = Popen(["C:\Program Files\Warcraft III\Frozen Throne.exe"]) > sleep(30) > print "slept for 30" > print win32api.TerminateProcess(int(war3game._handle),-1) > #print > ctypes.windll.kernel32.TerminateProcess(int(war3game._handle),-1) > print "terminated process" > > Here's the output: > slept for 30 > Traceback (most recent call last): > File "C:\Python24\warcraft\runwar3.py", line 7, in ? > print win32api.TerminateProcess(int(war3game._handle),-1) > error: (5, 'TerminateProcess', 'Access is denied.') > > I'm logged in as adminstrator. Does anyone know how to fix this > problem? > Thanks for your time, > Tom kill = Popen(['taskkill', war3game.pid]) *shrugs* maybe it is just taskill, or maybe you need the full path. don't recall as I quit using windows. Takskill on XP and newer maybe -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Pop Quiz
On Jun 1, 10:33 pm, [EMAIL PROTECTED] wrote: > 1. Do you like Python? 0 > 2. Do you think Python is good? 0 > 3. Do you think Python is real good? 0 > 4. What is your favorite version of Python? 2.4+ > 5. Because of Python, do you think it will be easier to take over the > world? If so, when? If not, when? from future import __all__ print "done" > 7. How many Z80 assembly language programmers does it take to equal > one Python guru? from z80 import guru > Essay: "C++ is better than C", agree or disagree? (four word maximum) sigh > Bonus: A rabbi walks into a bar while nursing a baby goat. He is > closely followed by a priest, and a Perl hacker. Explain. $_ -- http://mail.python.org/mailman/listinfo/python-list
Re: subprocess leaves child living
On Jun 5, 7:58 am, Thomas Dybdahl Ahle <[EMAIL PROTECTED]> wrote:
> Hi, When I do a small program like
>
> from subprocess import Popen
> popen = Popen(["ping", "google.com"])
> from time import sleep
> sleep(100)
>
> start it and kill it, the ping process lives on.
> Is there a way to ensure that the ping process is always killed when the
> python process is?
> I can't use atexit, as ping then isn't killed when python is killed "in
> the hard way"
pid = popen.pid
pidfile = open('/usr/local/var/somefile.pid', 'w')
pidfile.write('pid')
pidfile.close()
then you can check if it is still running when your ?program? restarts
and can kill it.
maybe not the perfect answer, but it answers an imperfect question.
--
http://mail.python.org/mailman/listinfo/python-list
Re: Progress count in terminal (Mac OS X)
> > for i in range(100): > > sys.stdout.write( "\r" + "count ", i,) >> sys.stdout.flush() > > print # done maybe Tommy Grav wrote: > This certainly does work when running the interpreter interactively, > but when inserted into a script it seems to buffer the print statement > and not write it out to the terminal. How can I force the print > statement > to not buffer the output? > > Cheers > Tommy > > On Jan 11, 2007, at 9:22 AM, Fredrik Lundh wrote: > > > Tommy Grav <[EMAIL PROTECTED]>: > > > >> I have a program that does a lot of iterations and would like > >> to follow its progress by having it print out the current iteration > >> number as it progresses. How do I do this so that it appears > >> like a counter that increases in the same place in the terminal > >> window? I am using python2.5 on a Mac OSX and its terminal > >> tcsh window. > > > > print a carriage return before, and no line feed after, each line: > > > > for i in range(100): > > print "\r" + "count", i, > > print # done > > > > > > > > > > > > -- > > http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Python development tools
在 2013年6月24日星期一UTC+8上午4时40分07秒,cutems93写道: > Hello, > > > > I am new to python development and I want to know what kinds of tools people > use for python development. I went to Python website and found several tools. > > > > 1. Automated Refactoring Tools > > 2. Bug Tracking > > 3. Configuration And BuildTools > > 4. Distribution Utilities > > 5. Documentation Tools > > 6. Integrated Development Environments > > 7. Python Debuggers > > 8. Python Editors > > 9. Python Shells > > 10. Test Software > > 11. Useful Modules > > 12. Version Control > > > > What else do I need? Also, which software is used in daily base? I know > version control software and bug tracking software are used almost everyday > by developers. Which software is used less often? > > > > Also, I will use GUI interface for Python. What kind of widget toolkits do > you recommend? I know there are GTK+ and Qt. > > > > Thank you in advance! > > -Min S.- It's a big question. -- http://mail.python.org/mailman/listinfo/python-list
wiki.python.org
Hello, I have been unable to access wiki.python.org for two days. Is there a problem with the server, or is it me? Thank you much, Kevin C. Reed New Python User -- http://mail.python.org/mailman/listinfo/python-list
Previous Question Answered - Thank You All For Your Replies
Hello, My question concerning wiki.python.org unavailability has been answered. Thank you all for your assistance! You guys are awesome! For those of you who don't know, here's the info. http://mail.python.org/pipermail/python-list/2013-January/638182.html Thanks again, Kevin -- http://mail.python.org/mailman/listinfo/python-list
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
Re: Appeal for python developers (THIS IS A TROLL)
On Saturday 05 March 2005 09:34, Thomas Rösner aka TRauMa wrote: > BOOGIEMAN wrote: > > Please include "goto" command in future python realeses > > I know that proffesional programers doesn't like to use it, > > but for me as newbie it's too hard to get used replacing it > > with "while", "def" or other commands > > Technically, as a newbie you shouldn't know about GOTO at all. So you're > more a "Tainted by previous spaghetti code practices"-guy than newbie. Or more likely a troll. Google for: Boogieman yahoo troll and you'll see this isn't the only place he/she does this sort of thing. Please don't feed the trolls. Dave -- http://mail.python.org/mailman/listinfo/python-list
Re: mxDateTime on Mac: Fatal Python Error
On Monday 07 March 2005 17:51, M.-A. Lemburg wrote: > [EMAIL PROTECTED] wrote: > > I'm trying to get mxDateTime working on a Mac so that I can use pyscopg > > and cx_Oracle. The Egenix base package builds and installs quite > > happily, but then when I try to import it I get > > > > > >>>import mx.DateTime > > > > Fatal Python error: Interpreter not initialized (version mismatch?) > > Abort > > > > ... any ideas? > > Messages like these are usually the result of a version mismatch > between the Python interpreter and the .so file of the extensions. > > Make sure you build the package using the same Python interpreter > you will later use it with. > > > Environment: > > > > OS X 10.3.8 > > sys.version: '2.3 (#1, Sep 13 2003, 00:49:11) \n[GCC 3.3 20030304 > > (Apple Computer, Inc. build 1495)]' > > egenix-mx-base-2.0.6 > > Hmm, this might also be some weird Mac OS issue. While we currently > don't support Macs directly, we do welcome suggestions to make them > work on your favorite platform. > > Thanks, > -- > Marc-Andre Lemburg > eGenix.com > Works fine for me on a 2004 PowerBook with 10.3.8. I'm using Python from DarwinPorts for pygtk and am using mx.DateTime with it. I don't remember if DarwinPorts had mx.DateTime or if I downloaded the source and installed it myself. I suspect it's the version mismatch problem mentioned above. 502 mac:~ $ /opt/local/bin/python Python 2.3.4 (#1, Nov 9 2004, 21:05:33) [GCC 3.3 20030304 (Apple Computer, Inc. build 1666)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import mx.DateTime >>> Dave -- http://mail.python.org/mailman/listinfo/python-list
Re: Protecting Python source
On Monday 29 November 2004 14:13, Grant Edwards wrote: > On 2004-11-29, Peter Maas <[EMAIL PROTECTED]> wrote: > > > If the "reverse engineering" argument boils down to "protecting source > > doesn't make sense" then why does Microsoft try so hard to protect > > its sources? > > To avoid embarassment. +1 QOTW -- http://mail.python.org/mailman/listinfo/python-list
Re: system requirements for python 2.4
On Monday 13 December 2004 18:17, Martin v. Löwis wrote: > ben wrote: > > I'm trying to upgrade python from 2.2 to 2.4 on a RH9 system, and can't > > find any rpm that will let me install it. > > Is FC3 required for python 2.4? > > No. However, you may have to build Python yourself. Try using the source > RPM; if that fails to work, either correct the spec file, or build > directly from the pydotorg sources. > > Regards, > Martin And you don't want to install an rpm with 2.4 that overwrites the 2.2 version that came with Red Hat. Many of the Red Hat configurations tools rely on the existing 2.2 version so you need to keep it there. You want to install python 2.4 somewhere else (/usr/local is the usual place). It really isn't difficult. Grab the .tgz file and untar it, cd into the python directory, execute "./configure; make;make install" assuming you have write permissions on /usr/local; if not su to root before doing "make install". Dave -- http://mail.python.org/mailman/listinfo/python-list
Re: Redirecting ./configure --prefix
On Monday 13 December 2004 21:15, Dan wrote: > I suspect this isn't specifically a Python question, but I > encountered it with Python so I thought I'd ask here. > > I'm running Linux (Fedora 2), and just downloaded the Python 2.4 > kit. I did the following from my user account: > ./configure --prefix=/some/private/dir --enable-shared > make > make test # all was okay > make install > > Now, when I try to run this I get the following error: > python: error while loading shared libraries: > libpython2.4.so.1.0: cannot open shared object file: No such > file or directory > > This library is in /some/private/dir/lib, but that directory is > not being searched. > > So, I have these questions: > - Can I get Python to search /some/private/dir/lib for >library files? > - Will sys.path be okay? How can I make it okay? > - Is there anything else I need to worry about? I think you just need to this if your shell is bash (default shell in FC2 I think) LD_LIBRARY_PATH=/some/private/dir/lib; export LD_LIBRARY_PATH or if you're using csh or tcsh setenv LD_LIBRARY_PATH /some/private/dir/lib If that works, you can put this in the appropriate dot file so you don't have to retype them each time you login/create a new shell. For bash I think it's ~/.bashrc or ~/.profile and for csh it's ~/.cshrc and ~/.tcshrc for tcsh. HTH, Dave -- http://mail.python.org/mailman/listinfo/python-list
Re: what would you like to see in a 2nd edition Nutshell?
On Wednesday 29 December 2004 18:01, Alex Martelli wrote: > So -- ctypes is definitely getting a _mention_, at least... the issue > remains of whether we're talking one paragraph, like for all other > extending-tools that were already thus mentioned in the 1st edition, or > a couple of pages (I can't possibly spend 2-3 pages on each of a dozen > extending tools, much as I'd love to!). > > > > Perhaps a more resonable sugestion would be a short section on integration > > with native systems, e.g. an intro/overview to (non exhaustive list): > > > > psyco > > scipy.blitz/weave > > ctypes > > pyrex > > they all represent intreresting areas. Perhaps the section could end with > > some words on PyPy. > > Speaking as somebody who's participated in more than half of the pypy > sprints and hopes for more, I think pypy needs to be mentioned much > earlier, together with other "alternate implementations of Python". > > I do agree that vast coverage is outside the scope that the Nutshell's > size lets me aim for. However, mere mention appears to lead to a > serious risk of the pointer being entirely missed -- e.g. despite being > interested in these issues you appear to be unaware of p. 545 (1st ed). > Hmmm -- maybe I need to strike some kind of balance here (so what else > is new...;-). This discussion is making me think what would be really nice is an advanced Python book that discusses many of the topics mentioned in this message and earlier messages in the thread. I'd rather see an in-depth advanced book than light coverage of the topics added to a Nutshell book. I own at least 8 or 9 Python books now and the 3 that I keep within arms reach of the computer are Nutshell, Cookbook, and Python Essential Reference. Dave 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: How to parse the os.system() output in python
On Mar 17, 2007, at 8:28 PM, [EMAIL PROTECTED] wrote: > Hi, > > I use os.system() to execute a system command in python. > Can you please tell me how can I parse (in python) the output of the > os.system() ? > > Thank you. Sounds like you want os.popen, not os.system. http://docs.python.org/lib/module-popen2.html 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: [Tutor] Spaces and tabs messing up code
On Jan 8, 2008, at 7:49 PM, Bill Campbell wrote: > On Tue, Jan 08, 2008, [EMAIL PROTECTED] wrote: >> >> my friend uses vim Small editors for small minds;) >> >> and i use xemacs >> >> so our shared python code is a mix of tabs and spaces and it is >> hard >> for him to edit it in vim >> >> any idea on how to make it clean >> >> convert it all to 4 spaces? > > Do that, and in his ~/.vimrc file, add a line ``set expandtab'' Tell him to use emacs. > > (Friends don't let friends use emacs :-). > > Bill > -- > INTERNET: [EMAIL PROTECTED] Bill Campbell; Celestial Software LLC > URL: http://www.celestial.com/ PO Box 820; 6641 E. Mercer Way > FAX:(206) 232-9186 Mercer Island, WA 98040-0820; (206) > 236-1676 > > Giving money and power to government is like giving whiskey and car > keys to > teenage boys -- P.J. O'Rourke > ___ > Tutor maillist - [EMAIL PROTECTED] > http://mail.python.org/mailman/listinfo/tutor -- http://mail.python.org/mailman/listinfo/python-list
Re:Histogram and \lambda parameter of the laplacian curve.
even i am trying to generate this curve. are you able to generate this curve using matplotlib, because i was thinking to write a library for it. -- Andrew. >Thanks everyone for your earlier help. >I have to plot a histogram of values lets say [0.5,0.6,0.8,0.9].I guess the >histogram would show an exponential decay ie, the laplacian curve. >I need to find the \lambda parameter of this curve . >So please tell me if it be done through >http://matplotlib.sourceforge.net/and are there any other libraries >which can be used. >Thanks in advance. >Aditya -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Tidy module?
Is there an easy_installable egg with an interface to libtidy? I
found µTidy, but it looks like an inactive project, with no updates
since 2004, so I'm skeptical of its reliability. I found mxTidy, but
it's only available as part of some larger distribution, and I don't
want to replace my Python installation. Is there one out there that I
missed?
Preferably, it'd be a single module I can drop into my current Python
2.5 installation, ideally via easy_install, to get tidy functionality
without having to resort to os.popen("tidy").
Thanks in advance for any pointers.
--
http://mail.python.org/mailman/listinfo/python-list
Pythonically extract data from a list of tuples (getopt)
So the return value from getopt.getopt() is a list of tuples, e.g.
>>> import getopt
>>> opts = getopt.getopt('-a 1 -b 2 -a 3'.split(), 'a:b:')[0]; opts
[('-a', '1'), ('-b', '2'), ('-a', '3')]
what's the idiomatic way of using this result? I can think of several
possibilities.
For options not allowed to occur more than once, you can turn it into
a dictionary:
>>> b = dict(opts)['-b']; b
'2'
Otherwise, you can use a list comprehension:
>>> a = [arg for opt, arg in opts if opt == '-a']; a
['1', '3']
Maybe the usual idiom is to iterate through the list rather than using
it in situ...
>>> a = []
>>> b = None
>>> for opt, arg in opts:
... if opt == '-a':
... a.append(arg)
... elif opt == '-b':
... b = arg
... else:
... raise ValueError("Unrecognized option %s" % opt)
Any of the foregoing constitute The One Way To Do It? Any simpler,
legible shortcuts?
Thanks.
--
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
No trees in the stdlib?
Why no trees in the standard library, if not as a built in? I searched the archive but couldn't find a relevant discussion. Seems like a glaring omission considering the batteries included philosophy, particularly balanced binary search trees. No interest, no good implementations, something other reason? Seems like a good fit for the collections module. Can anyone shed some light? Thanks. -- Tom -- http://mail.python.org/mailman/listinfo/python-list
rotor replacement
I see rotor was removed for 2.4 and the docs say use an AES module provided separately... Is there a standard module that works alike or an AES module that works alike but with better encryption? cheers, reed -- http://mail.python.org/mailman/listinfo/python-list
introducing a newbie to newsgroups
Super Sorry for the extra traffic. ;-) -- http://mail.python.org/mailman/listinfo/python-list
