Re: Re: Bug: spurious indentation error
En Sat, 29 Sep 2007 01:43:53 -0300, Mridula Ramesh [EMAIL PROTECTED] escribi�: Lol, nope, I checked today too, and it happened again. Try running this as a script, not from the prompt - I got a SyntaxError on line 10 as expected. After correcting it, I got an `IndentationError: expected an indented block` on line 23, due to a long line being wrapped onto the next line. A syntax error may be reported some lines later than the actual mistake, if the following lines build a good construct. For example, a missing close parenthesis. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and SSL
Martin v. Löwis [EMAIL PROTECTED] writes: But how can I tell my Python program to trust my SSL certificate? Why do you want to tell it that? The SSL module will trust *any* server certificate, no need to tell it explicitly which ones to trust. Er, the whole idea of SSL is that you don't trust the connection. So failing to authenticate the other end is a security failure and SSL should not be used that way. From RFC 4346: Warning: Completely anonymous connections only provide protection against passive eavesdropping. Unless an independent tamper-proof channel is used to verify that the finished messages were not replaced by an attacker, server authentication is required in environments where active man-in-the-middle attacks are a concern. It's silly to worry about an eavesdropper being nosy enough to intercept your data passively, but somehow still expect them to be considerate enough to not use an MITM attack. Always use authentication if it's worth bothering with cryptographic security at all. Another plan for server to server communication might be to use a VPN rather than connection level SSL. That would simplify your application programming if you can set up the encrypted network at both ends. -- http://mail.python.org/mailman/listinfo/python-list
Re: your opinion on book Foundations of Python Network Programming?
On Sep 28, 12:10 pm, TheFlyingDutchman [EMAIL PROTECTED] wrote: I have not read this book but just wanted to say, in case you don't already know, they have Chapter 13 on FTP available as a free download at the publisher's web site: http://www.apress.com/book/view/1590593715 thanks for the link, i just downloaded the chapter. -- http://mail.python.org/mailman/listinfo/python-list
Re: python 2.5 and 3gb switch
why? I am asking if any one knows of a 3gb python build. The code runs successfully in lesser missions it just wont run in the extra memory available when I try to run it along with my other programs in a 3gb space. thanks for your reply though -- http://mail.python.org/mailman/listinfo/python-list
Re: your opinion on book Foundations of Python Network Programming?
On Sep 28, 12:38 pm, sean tierney [EMAIL PROTECTED] wrote: I just read it (though I bought it half a year ago...don't judge :). Author recommends Python 2.3 and above...and as far as I know the examples are good. And if anything IS outdated -- you'll be able to do some quick research to get you to where you need to be...and he does mention code several areas of change/addition/modification. (ie urllib and urllib2). He uses a couple of 3rd party projects too. I really liked the book. I think Goerzen did a good job. He addresses the code in the context of the problem the code is meant to solve, which I found helpful. That said, it's not a substitute for actually reading the code. ...if you haven't read the most recent edition of Programming Python by Mark Lutz (O'Reilly), I'd recommend that first. Programming Python covers (some) networking and everything else. More bang for the $$. Sean Sean, thanks for your review and recommendation of the book Programming Python. atm, i'm looking for a book that has detailed coverage on networking. so Foundations of ... seems to be a good choice for me. -- http://mail.python.org/mailman/listinfo/python-list
Re: C Source Code Generator For Test Cases
On Fri, 28 Sep 2007 12:57:49 -0700, gamename wrote: How about using c-types to access your C-stuff to test, and use python + the testcase-tables to invoke that? Sure, that's possible. But the source code for tests (once all the parms are read) still needs to be generated. Calling the lib from python or from C, there still needs to be a way to generate 100+ test routines. ;-) Instead of reading the testcase tables and generating source for test routines you simply can do the tests right away. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and SSL
But how can I tell my Python program to trust my SSL certificate? Why do you want to tell it that? The SSL module will trust *any* server certificate, no need to tell it explicitly which ones to trust. Er, the whole idea of SSL is that you don't trust the connection. Please try to understand that OP's question. He got some error, and for some reason, he concluded that he needs to tell Python to trust the server certificate (most likely to make the error go away). I told him that he is likely wrong, and that Python already trusts his server certificate. I was not proposing any judgment on whether that's a good thing or not. In fact, I have no idea whether security was of any concern to the OP. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: python 2.5 and 3gb switch
The code runs successfully in lesser missions it just wont run in the extra memory available when I try to run it along with my other programs in a 3gb space. Still, it would be helpful if you explained how wont run manifests: does it fail to start, does it give you an exception, does it crash, does it erase your hard disk? I'm not aware of a 3gb Python build, but you should be able to build it yourself. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3.0 migration plans?
On Fri, 28 Sep 2007 09:56:48 -0400, Stephan Deibel wrote: Ian Dickinson wrote: Never would look like a good time scale to me given that a lot of the stuff I use is being ripped out Has any one actually converted any real code or significant bits of code using the 3.0 converter (in the sandbox somewhere), and if so what kinds of things actually failed? Well, since the converter is designed to convert 2.6 and above, and since there isn't much Python 2.6 code out there yet, I'd say nothing significant. :) Anyways, it is not designed to convert arbitrary code that's lying around: it's designed to convert a supported subset of Python 2.6+ into Python 3.0. You'd have to write transitional Python to use the tool. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3.0 migration plans?
On Fri, 28 Sep 2007 09:56:48 -0400, Stephan Deibel wrote: Ian Dickinson wrote: Never would look like a good time scale to me given that a lot of the stuff I use is being ripped out Has any one actually converted any real code or significant bits of code using the 3.0 converter (in the sandbox somewhere), and if so what kinds of things actually failed? Well, since the converter is designed to convert 2.6 and above, and since there isn't much Python 2.6 code out there yet, I'd say nothing significant. :) Anyways, it is not designed to convert arbitrary code that's lying around: it's designed to convert a supported subset of Python 2.6+ into Python 3.0. You'd have to write transitional Python to use the tool. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: Reentrancy of Python interpreter
On Sep 28, 11:31 pm, Brad Johnson [EMAIL PROTECTED] wrote: I have embedded a single threaded instance of the Python interpreter in my application. I have a place where I execute a Python command that calls into C++ code which then in turn calls back into Python using the same interpreter. I get a fatal error which is PyThreadStage_Get: no current thread. I guess I understand why I can't have two invocations of the same interpreter thread in one call stack, but how would I go about solving this? Looks like ( from PyThreadStage_Get error ) that you lost the GIL. You probably entered some C++ code and encapsulated you're work in the Py_BEGIN_ALLOW_THREADS code Py_END_ALLOW_THREADS but you're code is calling back the Python function, and you forgot to acquire back the GIL. -- http://mail.python.org/mailman/listinfo/python-list
Re: The Modernization of Emacs: terminology buffer and keybinding
Damien Kick wrote: Giorgos Keramidas wrote: On Fri, 22 Jun 2007 23:08:02 -, [EMAIL PROTECTED] wrote: So much for the free in free software. If you can't actually use it without paying money, whether for the software or for some book, it isn't really free, is it? Please do not confuse the term 'free' in 'free software' with 'gratis'. 'Gratis', i.e. 'lacking a monetary price tag' is something *very* different from the meaning of 'free' in 'free software'. Sure, but where does the infection thing come in? Suppose RMS publishes a new library call add-42, whose api is add-42, inputs n, outputs n+42, source left as an exercise, and Kenny decides he can use it, it is great. Now if Kenny uses it in his commercial software, add-42 does not somehow become less free to ride 'neath the starry skies above, don't fence me in. But RMS wants Kenny's hide. Nothing Kenny wrote derived from add-42, but RMS wants it all. Kenny happened to solve the traveling salesman problem and protein-folding and passed the fricking Turing test by using add-42 wherever he needed 42 added to a number, and RMS wants credit and ownership and control of it all. He and his license shall now dictate access and use of all that code. The handcuffs are on, and they are inscribed free. No wonder the GPL has gone nowhere. Freely. RMS reasonably wanted that add-42 not get co-opted, but that in no way necessitated the land grab that is GPL. The GPL is a gratuitous reach only fancifully justified by wanting to ensure that open source remain open. So this has nothing to do with freedom in /any/ sense of the word, it has to do with a political agenda opposed to the idea of private property. kzo -- http://www.theoryyalgebra.com/ We are what we pretend to be. -Kurt Vonnegut -- http://mail.python.org/mailman/listinfo/python-list
Re: python 2.5 and 3gb switch
On Sat, 29 Sep 2007 18:10:22 +1200, neil wrote: why? An error traceback or any other information might help us understand the problem. Even if you think you know what the issue is--and you didn't seem 100% certain--an example would help other people understand the issue better. I am asking if any one knows of a 3gb python build. The code runs successfully in lesser missions it just wont run in the extra memory available when I try to run it along with my other programs in a 3gb space. thanks for your reply though You're probably out of luck. Blender uses a built-in Python interpreter, which means you're stuck with whatever version it uses. If you were to install a different version of Python, Blender wouldn't use it--it would still use it's built-in version. (On Windows, I'm not sure if Blender ships with the Python DLL or if Python is statically linked in. If Blender does ship with the Python DLL, you could try to replace the DLL it ships with with the DLL from a 64-bit build of Python, but it would almost certainly crash Blender because the function signatures would be different. Hell, much lesser changes can cause problems: it is because of Blender that I compile Python in UCS-4 mode.) There is another possibility: perhaps it is a 64-bit version of Python built into Blender, but you need some standard libraries not supplied by Blender. (This is something a traceback might have been able to help us find out.) Does your conversion utility depend on having Python installed? If so, then installing a 64-bit version could help. But, it still behooves you to install the exact same version of Python, preferrably built with the same options. I can't help you there, though; don't run Windows myself. Did you look at the Active State distros? Maybe they have one. And finally, asking on the Blender forums would probably be more helpful. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and SSL
Martin v. Löwis [EMAIL PROTECTED] writes: Please try to understand that OP's question. He got some error, and for some reason, he concluded that he needs to tell Python to trust the server certificate (most likely to make the error go away). I told him that he is likely wrong, and that Python already trusts his server certificate. I was not proposing any judgment on whether that's a good thing or not. In fact, I have no idea whether security was of any concern to the OP. Oh, I see, I didn't interpret the question that way but it does fit and the answer is reasonable in that situation. -- http://mail.python.org/mailman/listinfo/python-list
Re: python 2.5 and 3gb switch
no sir nothing spectacular like that, I'll explain further - The .blend file I have is 550mb It originates from 13,000+ meshes imported from Solidworks ( 3d CAD program) of a piece of machinery. A python script was used for this purpose -it also performed some other tasks on the meshes like matching materials from a library and identifying sharp edges for normals in the renderer. This part was not a problem - the commit space reached 2,4 gb The next step is to export it in parts of about 2 million faces each in a file format Indigo uses. I need to save and reopen to unload commit space to do that... this means I have about 1.4gb commit. If I start the export script it will run fine until just about the end - this consumes another 700mb - ( I have the max MS recommends -2.9gb- set in the 3gb switch to play with and I actually know this is the limit cos I've hit that too..) Right at this point I still have 800mb available but here's the kicker - It needs about the same 550mb to complete the save.I know this from previous work on lesser files. This is where python gives 'memerror'. Although the space is there it wont use it. I believe I should be using Python that is 3gb enabled as well This is the same error I ran across doing smaller tasks without the switch btw Blender does not crash. HTH Neil -- http://mail.python.org/mailman/listinfo/python-list
Re: python 2.5 and 3gb switch
This is where python gives 'memerror'. Although the space is there it wont use it. It's still not clear to me. Please be as precise and literal as you can when reporting error messages. I very much doubt that Python outputs memerror at some point to the terminal; the string 'memerror' does not occur in the entire Python source code. There are things in Python that have a similar spelling, but again, please copy that spelling (and any additional output that surrounds that text) literally, rather than rephrasing it. I believe I should be using Python that is 3gb enabled as well I'm not so sure about that, with your description right now. There might be other reasons that cause that error (but they are hard to guess as still still don't know exactly what the error is). Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
question about for cycle
Hi all, I have the following code: for i in generator_a: # the first for cycle for j in generator_b: if something_happen: # do something here ..., I want the outer cycle to break break What should I do if I want the outer for cycle to continue or break ? If I put a continue or break in the inner cycle, it has no effect on the outer cycle. And I have another question. Which is the most efficient way to check if there are duplicate items in a list ? The items in the list may cannot be hashed, so set() may not work on the list. Regards, -- http://mail.python.org/mailman/listinfo/python-list
Professional Grant Proposal Writing Workshop (December 2007: University of Washington, Seattle)
The Grant Institute: Certificate in Professional Program Development and Grant Communication will be held at the University of Washington, Seattle, December 10 - 14, 2007. Interested development professionals, researchers, faculty, and graduate students should register as soon as possible, as demand means that seats will fill up quickly. Please forward, post, and distribute this e-mail to your colleagues and listservs. All participants will receive certification in professional grant writing from the Institute, as well as 3.5 CEU units. For more information call (888) 824 - 4424 or visit The Grant Institute at www.thegrantinstitute.com Please find the program description below: The Grant Institute Certificate in Professional Program Development and Grant Communication will be held at the University of Washington, Seattle Seattle, Washington December 10 - 14, 2007 8:00 AM - 5:00 PM The Grant Institute: Certificate in Professional Program Development and Grant Communication is a five-day intensive and interactive experience in which participants will be led through the program development, grant writing, and funding acquisition processes through the completion of four courses. The Grant Institute is not a seminar. Participants will actively engage in exercises and activities designed to strengthen their mastery of grant acquisition. Through the completion of varying assignments, students will leave The Grant Institute with a real grant proposal outline complete with quality research, solid content, and expert review. The Grant Institute focuses on combining the fundamentals of grant proposal writing with expert knowledge of communication principles such as Strategic Research, Persuasion, Argumentation, and Framing. The Grant Institute trainers and consultants do not merely lecture participants, but act as personal consultants and coaches dedicated to encouraging participants to succeed beyond their own expectations. While The Grant Institute uses collaboration and small groups for many exercises, each participant will work on their organization's pro ject. Participants are not overwhelmed with negativity or discouragement, but will be given the highest level of expertise to generate confidence in pursuing any funding project. At The Grant Institute , participants don't j ust learn to write grant proposals from top to bottom. Participants become specialists in our unique area of expertise: Grant Communication. Simply put, this is not your grandfather's grantwriting workshop. Our graduates are strategic, innovative, and confident. Whether you are new to professional grantwriting, or an experienced professional, you will not want to miss The Grant Institute. The Grant Institute consists of four (4) courses that will be completed during the five-day workshop. (1) Program Development and Evaluation This course is centered around the belief that "it's all about the program." This intensive course will teach professional program development essentials and program evaluation. While most grantwriting "workshops" treat program development and evaluation as separate from the writing of a proposal, this class will teach students the relationship between overall program planning and all strategic communication, including grantwriting. Consistent in our belief in grant communication, this class encourages students to understand successful program development and to think strategically about funding as an integral part of the overall program planning process. This class turns students into experts by teaching how to take ideas and concepts and turn them into professionally developed programs. (2) Advanced Grant Writing Designed for both the novice and experienced grantwriter, this course will make each student an overall fundraising communication specialist. In addition to teaching the basic components of a grant proposal, successful approaches, and the do's and don'ts of grantwriting, this course is infused with expert principles that will lead to a mastery of the process. Strategy resides at the forefront of this course's intent to illustrate grantwriting as an integrated, multidimensional, and dynamic endeavor. Each student will learn to stop writing the grant and to start writing the story. Ultimately, this class will illustrate how each component of the grant proposal represents an opportunity to use proven techniques for generating support. (3) Strategic Grant Research At its foundation, this course will address the basics of foundation, corporation, and government grant research. However, this course will teach a strategic funding research approach that encourages students to see research not as something they do before they write a proposal, but as an integrated part of the grant seeking process. Students will be exposed to online and database research tools, as well as publications and directories which contain information about foundation, corporation, and government grant
4000 every month
Zamanla ne kadar çok para kazanmışsiniz kendiniz bile inanamiyacaksiniz. Bu gerçektir. Hayal ettiğiniz şeyleri gerçekleştirebilirsiniz. Eyleme geçmek düşünerek durmaktan daha iyidir. Bizde bir nakil var düşünen düşününceye kadar tevekkül eden menzile varmış. Sizde hayal ettiğiniz menzillere varabilirsiniz. Knedinize güvenin. Ben bunu yapabilirim. Arkadaşlarımı üye yapabilirim. Şimdiden sizleri kutlarım siz bu mektubu almakla şanslısınız. Çünkü sizing için bir yeni gün başliyor. Allah sürekliliğin, alem ise yeniliğin alanıdır. Yeniden yaratma ile ortaya çıkan alem hareketin, oluşun ve akışın alanıdır. Şu halde hareket ve yenilik alemin ruhudur...Allah'ta aslonan vahdet, alemde aslolan kesrettir Davet linkiniz: http://www.superteklif.com/redirect.aspx?rid=dQDJb1CgiuY_eql http://www.superteklif.com/redirect.aspx?rid=dQDJb1CgiuY_eql http://www.superteklif.com/redirect.aspx?rid=dQDJb1CgiuY_eql http://www.superteklif.com/redirect.aspx?rid=dQDJb1CgiuY_eql SüperTeklif Nedir? E-maillerinizde, cep telefonlarınızda, TV'lerde, radyoda, metroda, sokakta... Kısaca her gün sayısız reklamla karşı karşıya kalıyorsunuz. Ama kimse size para ödemiyor. Gelin şimdi, gördüğünüz her reklamdan para kazanın! SüperTeklif'te; · E-mailinize gelen reklam ve anketlerden, · Cep telefonunuza gelen SMS reklamlarından, · Ev adresinize gönderilen ücretsiz promosyon ürünleri hakkında vereceğiniz fikir ve görüşlerden, · Size önereceğimiz ve profilinize uygun web sitelerine üye olarak, · ClubCard anlaşmalı e-ticaret sitelerinden yaptığınız alışverişlerde, · Sizin referansınızla üye olan arkadaşlarınızın gördüğü tüm reklamlardan sürekli Puan kazanırsınız. Bu puanlar 100,000'e ulaşınca da banka hesabınıza hemen 100 YTL olarak yatırılır. SüperTeklif'te Kazanmak Çok Kolay! Şimdi üye olun, sadece kişisel bilgilerinizi ve tercihlerinizi tamamlayarak hemen 5.000 Puan kazanın! Üstelik SüperTeklif'te sizin referansınızla üye olan arkadaşlarınızın gördüğü tüm reklamlardan da sürekli puan toplayacaksınız. SüperTeklif, yukarıda belirtilen pazarlama çalışmalarından elde ettiği net kazancın yüzde 45'ini üyelerine dağıtmaktadır. Unutmayın, izinli pazarlama prensibimiz gereği, günlük reklamlar ve anketler, sadece sizin istediğiniz sayı ve sıklıkta tarafınıza gönderilir. SüperTeklif üyeliği ücretsizdir. Ancak üye olmak için SüperTeklif üyesi bir arkadaşınız tarafından sisteme davet edilmelisiniz. Henüz davet edilmediyseniz üzülmeyin, şimdilik kayıt olmak için sistemden davet istemeniz yeterli! Ayrıca arkdaşlar bu yenilik bunuda okuyun bu çok super super teklif gibi her ikisine üye olun daha çok kazanç elde edin http://www.agloco.com/r/BBFR2592 www.agloco.com/r/BBFZ3904 www.agloco.com/r/BBGR9751 for marketing and win more Money plase do not forget to apply for this site too this very usefull link to win free please do not forget to apply http://www.clixsense.com/?2159840 www.agloco.com/r/BBFR6434 http://www.yuwie.com/yuwie.asp?r=102001 Dear __, I recently joined AGLOCO because of a friend recommended it to me. I am now promoting it to you because I like the idea and I want you to share in what I think will be an exciting new Internet concept. AGLOCO's story is simple: Do you realize how valuable you are? Advertisers, search providers and online retailers are paying billions to reach you while you surf. How much of that money are you making? NONE! AGLOCO thinks you deserve a piece of the action. AGLOCO collects money from those companies on behalf of its members. (For example, Google currently pays AOL 10 cents for every Google search by an AOL user. And Google still has enough profit to pay $1.6 billion dollars for YouTube, an 18-month old site full of content that YouTube's users did not get paid for! AGLOCO will work to get its Members their share of this and more. AGLOCO is building a new form of online community that they call an Economic Network. They are not only paying Members their fair share, but they're building a community that will generate the kind of fortune that YouTube made. But instead of that wealth making only a few people rich, the entire community will get its share. What's the catch? No catch - no spyware, no pop-ups and no spam - membership and software are free and AGLOCO is 100% member owned. Privacy is a core value and AGLOCO never sells or rents member information. So do both of us a favor: Sign up for AGLOCO right now! If you use this link to sign up, I automatically get credit for referring you and helping to build AGLOCO. http://www.agloco.com/r/BBFR2592 Agloco is the re-birth of AllAdvantage, which paid out over $100,000,000 to its members. * Agloco costs you nothing. It's free. And it always will be. * Agloco's Viewbar shows ads and lets you search the Web. Advertisers and search engines pay Agloco when you do that, and Agloco then pays you. * Agloco pays you by the hour to have that Viewbar open on your
Re: question about for cycle
On Sep 29, 11:04 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: ... What should I do if I want the outer for cycle to continue or break ? If I put a continue or break in the inner cycle, it has no effect on the outer cycle. I'd also be interested in the idiomatic solution to this one. I can see a number of solutions, from the ugly: for i in range(10): do_break = True for j in range(10): if j == 6: break else: do_break = False if do_break: break This will break the outer loop if the inner loop exited with a break. Using exceptions: for i in range(10): try: for j in range(10): print i, j if j == 6: raise MyException except MyException, e: break # or continue or whatever. Encapsulating in a function and using return: def get_value(): for i in range(10): for j in range(10): print i, j if j == 6: return fn(i, j) I guess to an extent it would depend on the exact situation as to which of these is more suitable. Are there any other recommended solutions to this? -- Ant... -- http://mail.python.org/mailman/listinfo/python-list
Balloon Taskbar Popup for Windows XP
Greetings, I need to create a function that will produce a balloon popup in the taskbar when called. Whats the shortest and easiest way to do this? Thanks. regards, Makko -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3.0 migration plans?
I've posted my vote. However, I guess it won't be that simple in practice. I suspect that the following is more likely: 1) Migrate to 3000 fairly soon after release for scripts and new projects for which required third party modules are available for 3k 2) Migrate existing projects to 3k a) when frameworks/modules that they use are available and b) if and when doing so would be advantageous. I suspect that many of the projects I have that are solid and are in no imminent need of development will remain 3k for several years. Cheers, -- Ant -- http://mail.python.org/mailman/listinfo/python-list
Re: python 2.5 and 3gb switch
thanks for your interest ...well I am quoting what it says - it gives me some recent lines executed in the console window and then 'memerror' possibly Blenders python API is slightly different from python itself I see there is a python exception MemoryError... most likely this is the equivalent and also using google I see other references to MemError or memerror I'll have to get back here tomorrow its late now I will get the exact statement for you -- http://mail.python.org/mailman/listinfo/python-list
Re: The Modernization of Emacs: terminology buffer and keybinding
On 2007-09-29 01:27:04 +0200, Damien Kick [EMAIL PROTECTED] said: Giorgos Keramidas wrote: On Fri, 22 Jun 2007 23:08:02 -, [EMAIL PROTECTED] wrote: So much for the free in free software. If you can't actually use it without paying money, whether for the software or for some book, it isn't really free, is it? Please do not confuse the term 'free' in 'free software' with 'gratis'. 'Gratis', i.e. 'lacking a monetary price tag' is something *very* different from the meaning of 'free' in 'free software'. If you were referring to the free in free Mumia Abu Jamal, I would agree with you. I don't think anyone would imagine that this phrase meant that someone was going to get Mumia Abu Jamal gratis. Like it or not, free software referring to free as in beer is probably the most common interpretation of the phrase for a native English speaker. Admittedly, I do not have a scientific survey handy. However, I just asked my wife--who has absolutely no interest in anything related to programming, has never heard of the FSF, Eric Raymond, nor the disagreement between those two camps, nor probably will she ever have an interest--what she thinks I mean when I say free software. After getting over the why are you asking such a stupid question phase, the first thing that jumped to her mind was free as in beer. You can stamp, growl, swagger, spit, curse, and bluster all you want on this point, but millions of English speakers are going to ignore you anyway. Lucky for most of them, they do not have to suffer the lectures of sociopolitically motivated language mavens trying to correct them from the error of mistaking the meaning of a phrase to be the normal meaning of that phrase. Fully true for non-native English speakers as well. Just did the wife test also - she is a pure software user - and yes, free is no money, do what you want and that's it. I *never* use the term free if I don't want to imply free beer (which is a Good Thing and as such highly valuated - ask any Bavarian). Using free as by FSF or any other lawyer-style 6 pixel font printed phrasing is pure perfidiousness. Frank -- Frank Goenninger frgo(at)goenninger(dot)net Don't ask me! I haven't been reading comp.lang.lisp long enough to really know ... -- http://mail.python.org/mailman/listinfo/python-list
earn $12800 a month
www.space666.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Delete spaces
On Sep 29, 1:43 am, [EMAIL PROTECTED] wrote: If I have a text file that is delimited by spaces, how do I import it and get to comma delimited? Here is a row of data from the text file: 1110:55:14 265 8.5 1.4+1.1 2.5 Class-2 0 I tried a few examples from the group and it didn't work, since the file also has a header row and a row of seperators ( ---). The lengths of each row is something like 130, so there are extra spaces after the last value as well. I have tried joining and other things, but I couldn't figure out how to get the values to come together. Thanks. Kou It would help enormously if you could show us UNAMBIGUOUSLY what is in say the first 3 lines after the headings and separators -- do this: print repr(open(thefile, rb).read()[:400]) The other thing you need is to know enough about the file format to show us what is the CSV output that you require from the sample input -- we don't have crystal balls, and are likely to make half-donkeyed guesses, like these: If the spaces are really tabs, use line.split('\t') Otherwise: the file has fixed column widths, and any use of line.split will mangle it. The clumsy way to handle this is to count column positions, and write something ugly like: field1 = line[0:8] field2 = line[8:20] etc a row of seperators ( ---) sounds suspiciously like the column aligned format that can be produced by running a SQL query on a SQL Server database using MS's Query Analyser. It looks like this: RecordType ID1 ID2 Description --- --- -- 1 12345678 123456 Widget 4 87654321 654321 Gizmoid etc Does your file look something like that? If so, then all you have to do is leverage off the fact that the second line has one-space gaps between each bunch of dashes, and you can write a little module that will read any file like that, just as though it were a CSV file. Over to you Cheers, John -- http://mail.python.org/mailman/listinfo/python-list
Re: question about for cycle
Ant wrote: On Sep 29, 11:04 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: ... What should I do if I want the outer for cycle to continue or break ? If I put a continue or break in the inner cycle, it has no effect on the outer cycle. I'd also be interested in the idiomatic solution to this one. I can see a number of solutions, from the ugly: for i in range(10): do_break = True for j in range(10): if j == 6: break else: do_break = False if do_break: break Here's a variant that doesn't need the flag inner = abc outer = xbz for i in outer: ... for k in inner: ... if i == k: ... print found, i ... break ... else: ... print i, not found ... continue ... break ... x not found found b but I usually prefer a helper function like this def get_value(): for i in range(10): for j in range(10): print i, j if j == 6: return fn(i, j) or this: def f(i, inner): ... for k in inner: ... if i == k: ... print found, i ... return True ... for i in outer: ... if f(i, inner): ... break ... print i, not found ... x not found found b Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: question about for cycle
Ant [EMAIL PROTECTED] wrote: On Sep 29, 11:04 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: ... What should I do if I want the outer for cycle to continue or break ? If I put a continue or break in the inner cycle, it has no effect on the outer cycle. ... I guess to an extent it would depend on the exact situation as to which of these is more suitable. Are there any other recommended solutions to this? I think the other Pythonic option you have missed is to convert the nested for loops into a single loop by writing a generator. def ranges(limit1, limit2): range1, range2 = range(limit1), range(limit2) for i in range1: for j in range2: yield i,j ... for i, j in ranges(10, 10): ... whatever ... if j==6: break -- http://mail.python.org/mailman/listinfo/python-list
Re: The Modernization of Emacs: terminology buffer and keybinding
Ken Tilton wrote: No wonder the GPL has gone nowhere. Bwaahahahaha. Keep smokin' that crack, there. Freely. RMS reasonably wanted that add-42 not get co-opted, but that in no way necessitated the land grab that is GPL. You (and probably KMP) are presuming the validity of copyright monopoly law think. Others do not do that. Whenever you claim a copyright monopoly, and enforce that monopoly, you're abridging others freedom. It might currently be legal to do so, but legal and right are different things. So your beef is not _really_ with the GPL - it derives all its power from copyright law. The GPL is really only valid while copyright law is: If copyright law is reduced in power and reach, the GPL is too. So if you don't like the GPL, push for weakened copyright law. Heh. Supporters of copyright monopoly law *really* don't like this double-bind of the GPL, of course, but that's by design. Of course, the FSF are a bunch of moderates, these days you can support your local Pirate Party, more information at http://www.pp-international.net/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3.0 migration plans?
On Sat, 2007-09-29 at 04:09 +, John Nagle wrote: [...] For example, MySQL AB supports a Perl binding to MySQL, but not a Python binding. And what's your point, other than that apparently MySQL AB doesn't care about Python? -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list
Re: question about for cycle
On Sep 29, 8:04 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: [snip] And I have another question. Which is the most efficient way to check if there are duplicate items in a list ? The items in the list may cannot be hashed, so set() may not work on the list. The following classic by Tim Peters answers the question How do I remove duplicate items from a list. http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52560 It should help -- provided of course that you mean duplicates in the sense that two Python objects a and b are duplicates iff a == b. If you mean duplicates in a fuzzier sense e.g. Mao Zedong and Mao Tse-Tung, the problem gets harder ... HTH, John -- http://mail.python.org/mailman/listinfo/python-list
Re: question about for cycle
On 29 sep, 12:04, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: for i in generator_a: # the first for cycle for j in generator_b: if something_happen: # do something here ..., I want the outer cycle to break break Do you like this? generator_ab = ((x, y) for x in generator_a for y in generator_b) for i, j in generator_ab: if condition: # do something break -- http://mail.python.org/mailman/listinfo/python-list
Re: sorteddict [was a PEP proposal, but isn't anymore!]
On 2007-09-27, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Is this a practical use case? When are sequential visits of all elements in order frequently suspended to make insertions and deletions, with a need for efficient lookup by key? Does it need to be a sequential visit of *all* elements? Suppose you have a mapping of start times to tasks. You can then want to iterate over all tasks that need to be started between noon en 4 pm next monday. If you have a hashtable you still will need to sort all the keys even if you will visit only 10%. If you have a tree you can just visit the specified keys. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
Re: sorteddict [was a PEP proposal, but isn't anymore!]
Antoon Pardon [EMAIL PROTECTED] wrote: On 2007-09-27, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Is this a practical use case? When are sequential visits of all elements in order frequently suspended to make insertions and deletions, with a need for efficient lookup by key? Does it need to be a sequential visit of *all* elements? Suppose you have a mapping of start times to tasks. You can then want to iterate over all tasks that need to be started between noon en 4 pm next monday. If you have a hashtable you still will need to sort all the keys even if you will visit only 10%. If you have a tree you can just visit the specified keys. It still depends on the exact pattern of use. If you have an implementation which tracks additions and deletions and sorts them into the list when required (as we came up with earlier) then this is much more efficient that re-sorting the whole list every time. Sorting a large sorted list with a few unsorted elements on the end is comparable to inserting the elements individually into a tree, and you still have the hashtable benefits on accessing elements to help level the playing field. For me though, the most convincing use-case for a sorted dictionary is one that I don't think has been mentioned yet: There are situations when you want to use a dictionary with existing library code that doesn't care about the random key ordering, but you have additional requirements which the original code didn't know about. For example, in the sorteddict code I added an implementation for the __repr__ method and an associated doctest. Unlike iteration over sorteddict itself, I didn't bother to make __repr__ stable, so in that particular doctest it only tests the repr of a sorteddict with a single element. If that was fixed to make the repr stable it would be a real benefit for writing any doctests which want to produce a dictionary as a result. Another example would be if you had a library which serialised a dictionary to xml. There is nothing wrong with the library if it doesn't care about order, but if you have some other reason why you want the xml to be stable (e.g. because you store it in a version control system and want to compare revisions) then a sorteddict would allow you to impose that behaviour on the library from outside. Contrary to my earlier insistence that sorteddict is only really useful if you can have a key parameter, both of these examples simply want an arbitrary but defined order of iteration for dictionary keys. A much simpler sorteddict that has been discussed earlier would be sufficient. -- http://mail.python.org/mailman/listinfo/python-list
Re: question about for cycle
[EMAIL PROTECTED] wrote: On 29 sep, 12:04, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: for i in generator_a: # the first for cycle for j in generator_b: if something_happen: # do something here ..., I want the outer cycle to break break Do you like this? generator_ab = ((x, y) for x in generator_a for y in generator_b) for i, j in generator_ab: if condition: # do something break In this case, the tuple generator_ab must be generated first. Sometime it maybe a waste to generate all possible combinations of i,j first. I have googled and found the PEP-3136(Labeled break and continue), which has been rejected. I have also read why Guido rejected this PEP( http://mail.python.org/pipermail/python-3000/2007-July/008663.html), but I still think labeled break and continue is a good feature in my case. Regards, -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3.0 migration plans?
On 9/28/07, TheFlyingDutchman [EMAIL PROTECTED] wrote: Correct me if I am wrong, but none of those examples showed something in C++ similar to a decorator in Python - that is, unique syntax in the language for implementing a Higher Order Function. One thing I will say about those examples is that they make Python decorators look sweet! That is exactly one of the points in having decorators, as far as I can tell. Namely, that higher order functions are easily implemented, if and when needed. Francesco -- http://mail.python.org/mailman/listinfo/python-list
Re: sorteddict [was a PEP proposal, but isn't anymore!]
On Sep 29, 4:23 pm, Duncan Booth [EMAIL PROTECTED] wrote: [...] Another example would be if you had a library which serialised a dictionary to xml. There is nothing wrong with the library if it doesn't care about order, but if you have some other reason why you want the xml to be stable (e.g. because you store it in a version control system and want to compare revisions) then a sorteddict would allow you to impose that behaviour on the library from outside. Contrary to my earlier insistence that sorteddict is only really useful if you can have a key parameter, both of these examples simply want an arbitrary but defined order of iteration for dictionary keys. A much simpler sorteddict that has been discussed earlier would be sufficient. In fact, a dictionary that maintains insertion order would work in this case too. -- bjorn -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and SSL
Paul Rubin wrote: Martin v. Löwis [EMAIL PROTECTED] writes: But how can I tell my Python program to trust my SSL certificate? Why do you want to tell it that? The SSL module will trust *any* server certificate, no need to tell it explicitly which ones to trust. Er, the whole idea of SSL is that you don't trust the connection. So failing to authenticate the other end is a security failure and SSL should not be used that way. From RFC 4346: Warning: Completely anonymous connections only provide protection against passive eavesdropping. Unless an independent tamper-proof channel is used to verify that the finished messages were not replaced by an attacker, server authentication is required in environments where active man-in-the-middle attacks are a concern. Right. The key point here is that Python's standard SSL module doesn't actually check the validity of SSL certificates. It just makes client connections without checking. It will happily connect to sites offering totally bogus certificates, even ones with the wrong domain name. M2Crypto actually checks. M2Crypto has much better functionality, but it's rather hard to build. John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: question about for cycle
On Sep 29, 10:34 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: On 29 sep, 12:04, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: for i in generator_a: # the first for cycle for j in generator_b: if something_happen: # do something here ..., I want the outer cycle to break break Do you like this? generator_ab = ((x, y) for x in generator_a for y in generator_b) for i, j in generator_ab: if condition: # do something break In this case, the tuple generator_ab must be generated first. It's not a tuple, it is a generator expression that can generate tuples *lazily*. Sometime it maybe a waste to generate all possible combinations of i,j first. It doesn't; read about generator expressions at http://www.python.org/dev/peps/pep-0289/ George -- http://mail.python.org/mailman/listinfo/python-list
Program inefficiency?
I wrote the following simple program to loop through our help files and fix some errors (in case you can't see the subtle RE search that's happening, we're replacing spaces in bookmarks with _'s) the program works great except for one thing. It's significantly slower through the later files in the search then through the early ones... Before anyone criticizes, I recognize that that middle section could be simplified with a for loop... I just haven't cleaned it up... The problem is that the first 300 files take about 10-15 seconds and the last 300 take about 2 minutes... If we do more than about 1500 files in one run, it just hangs up and never finishes... Is there a solution here that I'm missing? What am I doing that is so inefficient? # File: masseditor.py import re import os import time def massreplace(): editfile = open(pathname\editfile.txt) filestring = editfile.read() filelist = filestring.splitlines() ##errorcheck = re.compile('(a name=)+(.*)(-)+(.*)(/a)+') for i in range(len(filelist)): source = open(filelist[i]) starttext = source.read() interimtext = replacecycle(starttext) interimtext = replacecycle(interimtext) interimtext = replacecycle(interimtext) interimtext = replacecycle(interimtext) interimtext = replacecycle(interimtext) interimtext = replacecycle(interimtext) interimtext = replacecycle(interimtext) interimtext = replacecycle(interimtext) interimtext = replacecycle(interimtext) interimtext = replacecycle(interimtext) interimtext = replacecycle(interimtext) interimtext = replacecycle(interimtext) finaltext = replacecycle(interimtext) source.close() source = open(filelist[i],w) source.write(finaltext) source.close() ##if errorcheck.findall(finaltext)!=[]: ##print errorcheck.findall(finaltext) ##print filelist[i] if i == 100: print done 100 print time.clock() elif i == 300: print done 300 print time.clock() elif i == 600: print done 600 print time.clock() elif i == 1000: print done 1000 print time.clock() print done print i print time.clock() def replacecycle(starttext): p1= re.compile('(href=|HREF=)+(.*)(#)+(.*)( )+(.*)()+') p2= re.compile('(name=)+(.*)( )+(.*)()+') p3= re.compile('(href=|HREF=)+(.*)(#)+(.*)(\')+(.*)()+') p4= re.compile('(name=)+(.*)(\')+(.*)()+') p5= re.compile('(href=|HREF=)+(.*)(#)+(.*)(-)+(.*)()+') p6= re.compile('(name=)+(.*)(-)+(.*)()+') p7= re.compile('(href=|HREF=)+(.*)(#)+(.*)()+(.*)()+') p8= re.compile('(name=)+(.*)()+(.*)()+') p7= re.compile('(href=|HREF=)+(.*)(#)+(.*)(:)+(.*)()+') p8= re.compile('(name=)+(.*)(:)+(.*)()+') p9= re.compile('(href=|HREF=)+(.*)(#)+(.*)(\?)+(.*)()+') p10= re.compile('(name=)+(.*)(\?)+(.*)()+') p100= re.compile('(a name=)+(.*)(-)+(.*)(/a)+') q1= r\1\2\3\4_\6\7 q2= r\1\2_\4\5 interimtext = p1.sub(q1, starttext) interimtext = p2.sub(q2, interimtext) interimtext = p3.sub(q1, interimtext) interimtext = p4.sub(q2, interimtext) interimtext = p5.sub(q1, interimtext) interimtext = p6.sub(q2, interimtext) interimtext = p7.sub(q1, interimtext) interimtext = p8.sub(q2, interimtext) interimtext = p9.sub(q1, interimtext) interimtext = p10.sub(q2, interimtext) interimtext = p100.sub(q2, interimtext) return interimtext massreplace() -- http://mail.python.org/mailman/listinfo/python-list
Re: Program inefficiency?
[...] the program works great except for one thing. It's significantly slower through the later files in the search then through the early ones... Before anyone criticizes, I recognize that that middle section could be simplified with a for loop... I just haven't cleaned it up... The problem is that the first 300 files take about 10-15 seconds and the last 300 take about 2 minutes... If we do more than about 1500 files in one run, it just hangs up and never finishes... Is there a solution here that I'm missing? What am I doing that is so inefficient? The only thing I see is that you compile all of the RE's every time you call replacecycle(). They really only need to be compiled once, but I don't know why that would cause the progressive slowing. FWIW, it seems to me like a shell+sed script would be the obvious solution to the problem. # File: masseditor.py import re import os import time def massreplace(): editfile = open(pathname\editfile.txt) filestring = editfile.read() filelist = filestring.splitlines() ##errorcheck = re.compile('(a name=)+(.*)(-)+(.*)(/a)+') for i in range(len(filelist)): source = open(filelist[i]) starttext = source.read() interimtext = replacecycle(starttext) interimtext = replacecycle(interimtext) interimtext = replacecycle(interimtext) interimtext = replacecycle(interimtext) interimtext = replacecycle(interimtext) interimtext = replacecycle(interimtext) interimtext = replacecycle(interimtext) interimtext = replacecycle(interimtext) interimtext = replacecycle(interimtext) interimtext = replacecycle(interimtext) interimtext = replacecycle(interimtext) interimtext = replacecycle(interimtext) finaltext = replacecycle(interimtext) source.close() source = open(filelist[i],w) source.write(finaltext) source.close() ##if errorcheck.findall(finaltext)!=[]: ##print errorcheck.findall(finaltext) ##print filelist[i] if i == 100: print done 100 print time.clock() elif i == 300: print done 300 print time.clock() elif i == 600: print done 600 print time.clock() elif i == 1000: print done 1000 print time.clock() print done print i print time.clock() def replacecycle(starttext): p1= re.compile('(href=|HREF=)+(.*)(#)+(.*)( )+(.*)()+') p2= re.compile('(name=)+(.*)( )+(.*)()+') p3= re.compile('(href=|HREF=)+(.*)(#)+(.*)(\')+(.*)()+') p4= re.compile('(name=)+(.*)(\')+(.*)()+') p5= re.compile('(href=|HREF=)+(.*)(#)+(.*)(-)+(.*)()+') p6= re.compile('(name=)+(.*)(-)+(.*)()+') p7= re.compile('(href=|HREF=)+(.*)(#)+(.*)()+(.*)()+') p8= re.compile('(name=)+(.*)()+(.*)()+') p7= re.compile('(href=|HREF=)+(.*)(#)+(.*)(:)+(.*)()+') p8= re.compile('(name=)+(.*)(:)+(.*)()+') p9= re.compile('(href=|HREF=)+(.*)(#)+(.*)(\?)+(.*)()+') p10= re.compile('(name=)+(.*)(\?)+(.*)()+') p100= re.compile('(a name=)+(.*)(-)+(.*)(/a)+') q1= r\1\2\3\4_\6\7 q2= r\1\2_\4\5 interimtext = p1.sub(q1, starttext) interimtext = p2.sub(q2, interimtext) interimtext = p3.sub(q1, interimtext) interimtext = p4.sub(q2, interimtext) interimtext = p5.sub(q1, interimtext) interimtext = p6.sub(q2, interimtext) interimtext = p7.sub(q1, interimtext) interimtext = p8.sub(q2, interimtext) interimtext = p9.sub(q1, interimtext) interimtext = p10.sub(q2, interimtext) interimtext = p100.sub(q2, interimtext) return interimtext massreplace() -- Grant Edwards grante Yow! Are you still at SEXUALLY ACTIVE? Did you visi.comBRING th' REINFORCEMENTS? -- http://mail.python.org/mailman/listinfo/python-list
Re: Program inefficiency?
On Sat, 2007-09-29 at 15:22 +, [EMAIL PROTECTED] wrote: [...] def replacecycle(starttext): p1= re.compile('(href=|HREF=)+(.*)(#)+(.*)( )+(.*)()+') p2= re.compile('(name=)+(.*)( )+(.*)()+') p3= re.compile('(href=|HREF=)+(.*)(#)+(.*)(\')+(.*)()+') p4= re.compile('(name=)+(.*)(\')+(.*)()+') p5= re.compile('(href=|HREF=)+(.*)(#)+(.*)(-)+(.*)()+') p6= re.compile('(name=)+(.*)(-)+(.*)()+') p7= re.compile('(href=|HREF=)+(.*)(#)+(.*)()+(.*)()+') p8= re.compile('(name=)+(.*)()+(.*)()+') p7= re.compile('(href=|HREF=)+(.*)(#)+(.*)(:)+(.*)()+') p8= re.compile('(name=)+(.*)(:)+(.*)()+') p9= re.compile('(href=|HREF=)+(.*)(#)+(.*)(\?)+(.*)()+') p10= re.compile('(name=)+(.*)(\?)+(.*)()+') p100= re.compile('(a name=)+(.*)(-)+(.*)(/a)+') [...] One obvious opportunity for optimization is to compile those re's only once at the beginning of the program instead of every time replacecycle() is called (which is inexplicably called 13 times for each file). -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Program inefficiency?
I did try moveing the re.compile's up and out of the replacecylce() but it didn't impact the time in any meaningful way (2 seconds maybe)... I'm not sure what an shell+sed script is... I'm fairly new to Python and my only other coding experience is with VBA... This was my first Python program In case it helps... We started with only 6 loops of replacecycle() but had to keep adding progressively more as we found more and more links with lots of spaces in them... As we did that, the program's time grew progressively longer but the length grew multiplicatively with the added number of cycles... This is exactly what I would have expected and it leads me to believe that the problem does not lie in the replacecycle() def but in the masseditor() def... *shrug* -- http://mail.python.org/mailman/listinfo/python-list
Re: Program inefficiency?
[EMAIL PROTECTED] wrote: Is there a solution here that I'm missing? What am I doing that is so inefficient? Hi Jeff, Yes, it seems you have plenty of performance leaks. Please see my notes below. def massreplace(): editfile = open(pathname\editfile.txt) filestring = editfile.read() filelist = filestring.splitlines() ##errorcheck = re.compile('(a name=)+(.*)(-)+(.*)(/a)+') for i in range(len(filelist)): source = open(filelist[i]) Read this post: http://mail.python.org/pipermail/python-list/2004-August/275319.html Instead of reading the whole document, storing it in a variable, splitting it and the iterating, you could simply do: def massreplace(): editfile = open(pathname\editfile.txt) for source in editfile: starttext = source.read() interimtext = replacecycle(starttext) (...) Excuse me, but this is insane. Do just one call (or none at all, I don't see why you need to split this into two functions) and let the function manage the replacement layers. I'm skipping the next part (don't want to understand all your logic now). (...) def replacecycle(starttext): Unneeded, IMHO. p1= re.compile('(href=|HREF=)+(.*)(#)+(.*)( )+(.*)()+') (...) interimtext = p100.sub(q2, interimtext) Same euphemism applies here. I might be wrong, but I'm pretty confident you can make all this in one simple regex. Anyway, although regexes are supposed to be cached, don't need to define them every time the function gets called. Do it once, outside the function. At the very least you save one of the most important performance hits in python, function calls. Read this: http://wiki.python.org/moin/PythonSpeed/PerformanceTips Also, if you are parsing HTML consider using BeautifulSoup or ElementTree, or something (particularly if you don't feel particularly confident with regexes). Hope you find this helpful. Pablo -- http://mail.python.org/mailman/listinfo/python-list
RE: Program inefficiency?
-Original Message- From: [EMAIL PROTECTED] the program works great except for one thing. It's significantly slower through the later files in the search then through the early ones... Before anyone criticizes, I recognize that that middle section could be simplified with a for loop... I just haven't cleaned it up... The problem is that the first 300 files take about 10-15 seconds and the last 300 take about 2 minutes... If we do more than about 1500 files in one run, it just hangs up and never finishes... Is there a solution here that I'm missing? What am I doing that is so inefficient? You did not mention the OS, but because you are using pathname\editfile.txt, it sounds like you are using an MS OS. From past experience with various MS OSes, I found that as the number of files in a directory increases the slower your process runs for each file. You might try putting these files into multiple sub-directories. The information contained in this message and any attachment may be proprietary, confidential, and privileged or subject to the work product doctrine and thus protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify me immediately by replying to this message and deleting it and all copies and backups thereof. Thank you. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3.0 migration plans?
On Sep 27, 5:37 pm, Steve Holden [EMAIL PROTECTED] wrote: I wondered if a straw poll could get some idea of readers' thoughts about when they will be migrating to 3.0 on, so I used the new widget on Blogger to add a poll for that. I'd appreciate if if you would go to http://holdenweb.blogspot.com/ and register your vote on your intended migration timescale. Thanks! -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Sorry, the dog ate my .sigline I was thinking of starting work on converting Python FIT to 3.0, and then they posted PEP 3137. I think it's a real good idea, but it shows that 3.0a1 isn't ready for a conversion effort. http://www.python.org/dev/peps/pep-3137/ I'll look at it again in a year or so. John Roth -- http://mail.python.org/mailman/listinfo/python-list
Re: Program inefficiency?
On 2007-09-29, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I'm not sure what an shell+sed script is... http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_05_01.html#sect_05_01_01 http://tldp.org/LDP/Bash-Beginners-Guide/html/chap_05.html http://www.grymoire.com/Unix/Sed.html http://www.gnu.org/software/bash/ http://en.wikipedia.org/wiki/Bash Unfortuantely it appears you're using Windows (a partucular bad choice for this sort of file processing). You can, however, get bash and sed for Windows if you wish: http://www.cygwin.com/ In case it helps... We started with only 6 loops of replacecycle() but had to keep adding progressively more as we found more and more links with lots of spaces in them... I would think with the correct RE's you'd only have to call it once. As we did that, the program's time grew progressively longer but the length grew multiplicatively with the added number of cycles... This is exactly what I would have expected and it leads me to believe that the problem does not lie in the replacecycle() def but in the masseditor() def... *shrug* As the program runs on progressively more files does the process's memory usage grow without bounds? Does the machine start swapping? -- Grant Edwards grante Yow! I'm pretending that at we're all watching PHIL visi.comSILVERS instead of RICARDO MONTALBAN! -- http://mail.python.org/mailman/listinfo/python-list
Re: Program inefficiency?
XP is the OS... the files are split across a ton of subdirectories already... I'm actually starting to think there's a problem with certain files, however... We create help files for clients using RoboHelp... RoboHelp has Source HTML and then webhelp html which is what actually goes to the client... I'm trying to mass maintenance the source files... Right now, my program works but you've got to delete the webhelp files first... I figured that (based on the exponential growth in processing time) it was the additional number of files... However, after streamlining the codes I got the following results done 300 4.1904767226e-006 done 600 7.97062280262 done 900 22.3963802662 done 1200 29.9211888662 done 1375 35.3465962853 with the webhelp deleted and done 300 4.1904767226e-006 done 600 7.6259175398 done 900 13.3994678095 still processing 10 minutes later with the webhelp intact Since the system didn't hang sometime after 1375 (and in fact, still hasn't made it there), I can only assume that it hit one of the webhelp files and freaked out... The thing that's really weird is that the files it's hanging on appear to be some of the most basic files in the whole system (small, not alot going on... no hits on the RE search)... So I may just tell the users to delete the webhelp and have robohelp recreate it after they've run the program... -- http://mail.python.org/mailman/listinfo/python-list
Re: Program inefficiency?
no swaps... memory usage is about 14k (these are small Html files)... no hard drive cranking away or fan on my laptop going nutty... CPU usage isn't even pegged... that's what makes me think it's not some sort of bizarre memory leak... Unfortunately, it also means I'm out of ideas... -- http://mail.python.org/mailman/listinfo/python-list
Re: How to display a videostream in the PyQt GUI by a efficient way
On Sat Sep 29 05:12:25 CEST 2007, kivilaya wrote: As required, I need to get a videostream from a camera, and process every frame to add some information on it, and then display the frame in a PyQt GUI. But I don't know how to display the videostream in the PyQt GUI by a efficient way. Currently, I do these like this: 1. Get the videostream by the videocapture module (a useful module written by Markus Gritsch) in the format of PIL images; This sounds interesting. I wasn't aware of that module. 2. Process every PIL image and add the information; 3. Convert every PIL image to QPixmap and display it using QLabel.setPixmap. This could be quite inefficient, though I think there's some support for Qt's image classes in PIL these days. I think it is a very inefficient way, but I don't known how to display the videostream in other ways, so I need your help, Thanks! PS:I do it with Windows XP, Python 2.5.1, PyQt4.3.0 If you're using a commercially-licensed Qt library, you'll have access to the ActiveQt classes that can be used to embed ActiveX controls: http://doc.trolltech.com/4.3/activeqt.html Otherwise, you might find this recent thread on qt-interest to be of interest: http://lists.trolltech.com/qt-interest/2007-09/msg00806.html I also tried to document ways to do this on the PyQt/PyKDE Wiki: http://www.diotavelli.net/PyQtWiki/Multimedia_Resources David -- http://mail.python.org/mailman/listinfo/python-list
Re: Program inefficiency?
For anyone that cares, I figured out the problem... the webhelp files that it hits the wall on are the compiled search files... They are the only files in the system that have line lengths that are RIDICULOUS in length... I'm looking at one right now that has 32767 characters all on one line... I'm absolutely certain that that's the problem... Thanks for everyone's help -- http://mail.python.org/mailman/listinfo/python-list
Re: sorteddict [was a PEP proposal, but isn't anymore!]
thebjorn [EMAIL PROTECTED] wrote: On Sep 29, 4:23 pm, Duncan Booth [EMAIL PROTECTED] wrote: [...] Another example would be if you had a library which serialised a dictionary to xml. There is nothing wrong with the library if it doesn't care about order, but if you have some other reason why you want the xml to be stable (e.g. because you store it in a version control system and want to compare revisions) then a sorteddict would allow you to impose that behaviour on the library from outside. Contrary to my earlier insistence that sorteddict is only really useful if you can have a key parameter, both of these examples simply want an arbitrary but defined order of iteration for dictionary keys. A much simpler sorteddict that has been discussed earlier would be sufficient. In fact, a dictionary that maintains insertion order would work in this case too. It would be better than the current situation, but say I have elements 'a', 'b', and 'c'. Next run of the program I delete 'b', then the run after that I add 'b' back into the list so now I might get 'a', 'c', 'b'. Sorting would ensure that I can tell that I actually reverted a change. Right now I think there are probably three dict variants needed: sorteddict (still waiting for a convincing use case), ordereddict (lots of use cases), and this one: stabledict. -- http://mail.python.org/mailman/listinfo/python-list
xyz points and magnitude to intensity or colormap or contourmap
hi! how do you do contour maps with vtk? i have 3600 points for each point i have a corresponding magnitude. i plane to do contour maps that is i plot each point with a different color (representing its magnitude ) how can i do this with using python, matplotlib or vtk? does any one have a similar example please any thing to start wiht wil be good thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Program inefficiency?
On Sep 29, 5:22 pm, [EMAIL PROTECTED] wrote: I wrote the following simple program to loop through our help files and fix some errors (in case you can't see the subtle RE search that's happening, we're replacing spaces in bookmarks with _'s) the program works great except for one thing. It's significantly slower through the later files in the search then through the early ones... Before anyone criticizes, I recognize that that middle section could be simplified with a for loop... I just haven't cleaned it up... The problem is that the first 300 files take about 10-15 seconds and the last 300 take about 2 minutes... If we do more than about 1500 files in one run, it just hangs up and never finishes... Is there a solution here that I'm missing? What am I doing that is so inefficient? Ugh, that was entirely too many regexps for my taste :-) How about something like: def attr_ndx_iter(txt, attribute): Return all the start and end indices for the values of attribute. txt = txt.lower() attribute = attribute.lower() + '=' alen = len(attribute) chunks = txt.split(attribute) if len(chunks) == 1: return start = len(chunks[0]) + alen end = -1 for chunk in chunks[1:]: qchar = chunk[0] end = start + chunk.index(qchar, 1) yield start + 1, end start += len(chunk) + alen def substr_map(txt, indices, fn): Apply fn to text within indices. res = [] cur = 0 for i,j in indices: res.append(txt[cur:i]) res.append(fn(txt[i:j])) cur = j res.append(txt[cur:]) return ''.join(res) def transform(s): The transformation to do on the attribute values. return s.replace(' ', '_') def zap_spaces(txt, *attributes): for attr in attributes: txt = substr_map(txt, attr_ndx_iter(txt, attr), transform) return txt def mass_replace(): import sys w = sys.stdout.write for f in open(r'pathname\editfile.txt'): try: open(f, 'w').write(zap_spaces(open(f).read(), 'href', 'name')) w('.') # progress-meter :-) except: print 'Error processing file:', f minimally-tested'ly y'rs -- bjorn -- http://mail.python.org/mailman/listinfo/python-list
xml modifications
hi there...i'm a begginer level user and i've stumbbled upon a problem a bit beyond my knowledge. i hope that somebody will be able to help me with my problem... the problem is: i'm transforming an Access database to XML with some adjustements. basicaly i have one main table in which i have my main data and keys to other tables containing other relevant data. after exporting my main table to xml i have in some tags only keys to other tables. and now i want to change those keys to meaningful data. for instance: after exporting, i have a line like this: tagZ1/tagZ, and i want to change it to be just an opening tag for something else; tagQ attr1=xx attr2=yy.the data which must be written in attr1 and attr2 depends upon the number (in this case number 1) inside the tag (tagZ). -- http://mail.python.org/mailman/listinfo/python-list
Re: Program inefficiency?
thebjorn wrote: On Sep 29, 5:22 pm, [EMAIL PROTECTED] wrote: I wrote the following simple program to loop through our help files and fix some errors (in case you can't see the subtle RE search that's happening, we're replacing spaces in bookmarks with _'s) (...) Ugh, that was entirely too many regexps for my taste :-) How about something like: def attr_ndx_iter(txt, attribute): (...) def substr_map(txt, indices, fn): (...) def transform(s): (...) def zap_spaces(txt, *attributes): (...) def mass_replace(): (...) Oh yeah, now it's clear as mud. I do think that the whole program shouldn't take more than 10 lines of code using one sensible regex (impossible to define without knowing the real input and output formats). And (sorry to tell) I'm convinced this is a problem for regexes, in spite of anybody's personal taste. Pablo -- http://mail.python.org/mailman/listinfo/python-list
Re: sorteddict [was a PEP proposal, but isn't anymore!]
On Sep 29, 7:13 pm, Duncan Booth [EMAIL PROTECTED] wrote: [...] Right now I think there are probably three dict variants needed: sorteddict (still waiting for a convincing use case), ordereddict (lots of use cases), and this one: stabledict. What's stabledict? I'm assuming that ordereddict is a mapping that maintains insertion order(?) The only other mapping type I use very frequently is a dict where the keys are limited to valid identifiers, and where attribute lookup (d.foo) is defined as key lookup (d['foo']). It makes lots of code easier to read (and write). In the Smalltalk collection hierarchy SortedCollection is a subclass of OrderedCollection, which implies to me that it'd be better to add an ordereddict first. -- bjorn -- http://mail.python.org/mailman/listinfo/python-list
strange unbound local error?
hi folks, suppose this snipplet: spam = 42 def eggs(): print spam spam = spam + 1 if __name__==__main__: eggs() This thows an UnboundLocalError at line 4 (print statement). But if I comment out line 5 (variable assignment), no error occurs. Can you explain me this, please? Regards, Enrico -- http://mail.python.org/mailman/listinfo/python-list
Re: Program inefficiency?
On Sep 29, 7:55 pm, Pablo Ziliani [EMAIL PROTECTED] wrote: thebjorn wrote: On Sep 29, 5:22 pm, [EMAIL PROTECTED] wrote: I wrote the following simple program to loop through our help files and fix some errors (in case you can't see the subtle RE search that's happening, we're replacing spaces in bookmarks with _'s) (...) Ugh, that was entirely too many regexps for my taste :-) How about something like: def attr_ndx_iter(txt, attribute): (...) def substr_map(txt, indices, fn): (...) def transform(s): (...) def zap_spaces(txt, *attributes): (...) def mass_replace(): (...) Oh yeah, now it's clear as mud. I'm anxiously awaiting your beacon of clarity ;-) I do think that the whole program shouldn't take more than 10 lines of code Well, my mass_replace above is 10 lines, and the actual replacement code is a one liner. Perhaps you'd care to illustrate how you'd shorten that while still keeping it clear? using one sensible regex I have no doubt that it would be possible to do with a single regex. Whether it would be sensible or not is another matter entirely... (impossible to define without knowing the real input and output formats). Of course, but I don't think you can guess too terribly wrong. My version handles upper and lower case attributes, quoting with single (') and double () quotes, and any number of spaces in attribute values. It maintains all other text as-is, and converts spaces to underscores in href and name attributes. Did I get anything majorly wrong? And (sorry to tell) I'm convinced this is a problem for regexes, in spite of anybody's personal taste. Well, let's see it then :-) smack-smack'ly y'rs -- bjorn -- http://mail.python.org/mailman/listinfo/python-list
Re: strange unbound local error?
[EMAIL PROTECTED] wrote: spam = 42 def eggs(): print spam spam = spam + 1 if __name__==__main__: eggs() This thows an UnboundLocalError at line 4 (print statement). But if I comment out line 5 (variable assignment), no error occurs. Can you explain me this, please? Hi Enrico, You need to say that you will be modifying the variable in the global scope, like this: spam = 42 def eggs(): global spam # --here print spam spam = spam + 1 if __name__==__main__: eggs() This can help you: http://www.pasteur.fr/recherche/unites/sis/formation/python/ch04.html Pablo -- http://mail.python.org/mailman/listinfo/python-list
Re: strange unbound local error?
On Sep 29, 8:04 pm, [EMAIL PROTECTED] wrote: hi folks, suppose this snipplet: spam = 42 def eggs(): print spam spam = spam + 1 if __name__==__main__: eggs() This thows an UnboundLocalError at line 4 (print statement). But if I comment out line 5 (variable assignment), no error occurs. Can you explain me this, please? Regards, Enrico If you're going to assign to a global variable in a function, you need to declare it as such: spam = 42 def eggs(): global spam print spam spam = spam + 1 When Python sees an assignment to an identifier in a function it creates a variable that is local to the function (otherwise you'd be unable to create local variables with the same name as any of the global variables). -- bjorn -- http://mail.python.org/mailman/listinfo/python-list
Re: Program inefficiency?
The search is trying to replace the spaces in our bookmarks (and the links that go to those bookmarks)... The bookmark tag looks like this: a href=Web_Sites.htm#A Web Sites and the bookmark tag looks like this a name=A Web Sites/a some pitfalls I've already run up against... SOMETIMES (but not often) the a and the href (or name) is split across a line... this led me to just drop the a from the front If there are no spaces, SOME (but again, not all) of the a name tags don't have 's... this is a problem because we're having to replace all special characters with _'s... Some of our bookmarks are quite wordy (we found one yesterday with 11 spaces) href is sometimes all caps (HREF) As you can imagine, there are alot of corner cases and I felt it was easier just to be inefficient and write out all the regex cases and loop through them repeatedly... I've also got to work around the stuff already in the system (for example, I need to make certain I'm looking behind the #'s in the bookmark links, otherwise I'll end up replacing legitimate -'s in external web site addresses) I think Pablo is correct that a single (or perhaps two) RE statements are all that is needed... perhaps: p1= re.compile('(href=|HREF=)+(.*)(#)+(.*)(\w\'\?-: )+(.*)()+') and the corresponding name replace and then the one corner case we ran into of p100= re.compile('(a name=)+(.*)(-)+(.*)(/a)+') -- http://mail.python.org/mailman/listinfo/python-list
Re: Program inefficiency?
It think he's saying it should look like this: # File: masseditor.py import re import os import time p1= re.compile('(href=|HREF=)+(.*)(#)+(.*)(\w\'\?-:)+(.*)()+') p2= re.compile('(name=)+(.*)(\w\'\?-:)+(.*)()+') p100= re.compile('(a name=)+(.*)(-)+(.*)(/a)+') q1= r\1\2\3\4_\6\7 q2= r\1\2_\4\5 def massreplace(): editfile = open(C:\Program Files\Credit Risk Management\Masseditor \editfile.txt) filestring = editfile.read() filelist = filestring.splitlines() for i in range(len(filelist)): source = open(filelist[i]) starttext = source.read() for i in range (13): interimtext = p1.sub(q1, starttext) interimtext= p2.sub(q2, interimtext) interimtext= p100.sub(q2, interimtext) source.close() source = open(filelist[i],w) source.write(finaltext) source.close() massreplace() I'll try that and see how it works... -- http://mail.python.org/mailman/listinfo/python-list
wxpython combined with vpython
One question. I didn't try it, just one idea Is it possible to put a Vpython window inside a WX frame like it is a part of the wxframe between sizers or anything els -- http://mail.python.org/mailman/listinfo/python-list
Re: Program inefficiency?
On Sep 29, 8:32 pm, [EMAIL PROTECTED] wrote: It think he's saying it should look like this: # File: masseditor.py import re import os import time p1= re.compile('(href=|HREF=)+(.*)(#)+(.*)(\w\'\?-:)+(.*)()+') p2= re.compile('(name=)+(.*)(\w\'\?-:)+(.*)()+') p100= re.compile('(a name=)+(.*)(-)+(.*)(/a)+') q1= r\1\2\3\4_\6\7 q2= r\1\2_\4\5 def massreplace(): editfile = open(C:\Program Files\Credit Risk Management\Masseditor \editfile.txt) filestring = editfile.read() filelist = filestring.splitlines() for i in range(len(filelist)): source = open(filelist[i]) starttext = source.read() for i in range (13): interimtext = p1.sub(q1, starttext) interimtext= p2.sub(q2, interimtext) interimtext= p100.sub(q2, interimtext) source.close() source = open(filelist[i],w) source.write(finaltext) source.close() massreplace() I'll try that and see how it works... Ok, if you want a single RE... How about: test = ''' a href=Web_Sites.htm#A Web Sites a name=A Web Sites/a a href=Web_Sites.htm#A Web Sites a name=A Web Sites/a a HREF=Web_Sites.htm#A Web Sites a name=Quoteless/a a name = oo ps/a ''' import re r = re.compile(r''' (?:href=['][^#]+[#]([^']+)[']) | (?:name=[']?([^']+)) ''', re.IGNORECASE | re.MULTILINE | re.DOTALL | re.VERBOSE) def zap_space(m): return m.group(0).replace(' ', '_') print r.sub(zap_space, test) It prints out a href=Web_Sites.htm#A_Web_Sites a name=A_Web_Sites/a a href=Web_Sites.htm#A_Web_Sites a name=A_Web_Sites/a a HREF=Web_Sites.htm#A_Web_Sites a name=Quoteless/a a name = oo ps/a -- bjorn -- http://mail.python.org/mailman/listinfo/python-list
Re: Program inefficiency?
On Sep 29, 6:07 pm, [EMAIL PROTECTED] wrote: You did not mention the OS, but because you are using pathname\editfile.txt, it sounds like you are using an MS OS. From past experience with various MS OSes, I found that as the number of files in a directory increases the slower your process runs for each file. how so? -- http://mail.python.org/mailman/listinfo/python-list
CaFeCONF 2007 6tas. Conferencias Abiertas de Software Libre y GNU/Linux
We are going to have a few speeches about python language. http://www.cafeconf.org/2007/modules/myconference/program.php?cid=1programord=1 cheers, CaFeCONF 2007 6tas. Conferencias Abiertas de Software Libre y GNU/Linux (CaFeCONF) http://www.cafeconf.org Está abierta la inscripción para participar de las 6tas. Conferencias Abiertas de Software Libre y GNU/Linux CaFeCONF 2007, organizadas por el Grupo de Usuarios de Software Libre de Capital Federal (CaFeLUG), a realizarse los días *5 y 6 de Octubre* en la sede de la Universidad Argentina de la Empresa *(UADE), Lima 717*, Ciudad de Buenos Aires, Argentina. Con más de 70 charlas, talleres y conferencias, CaFeCONF es un evento de difusión y capacitación donde expertos, entusiastas y usuarios exponen, comparten, difunden, debaten y se capacitan en una amplia gama de temáticas relacionadas al uso y desarrollo de Software Libre. Este año contamos con el apoyo de Google, Red Hat, el Proyecto Fedora, Globant, Intel y tecso entre nuestros sponsors. Contaremos con la participación de Enrique Chaparro como keynote del evento. Y una nueva edición de Aulas Libres, el evento educativo co-organizado por Gleducar. Aulas Libres tiene como objetivo ser un espacio de encuentro entre educadores libres, un lugar para reflexionar y debatir sobre las problemáticas de la educación en relación a las nuevas tecnologías, el Software Libre y la construcción cooperativa de conocimientos. Pueden visualizar el programa completo del evento: http://www.cafeconf.org/2007/modules/myconference/program.php?cid=1programord=1 La participación en CaFeCONF es libre y gratuita. La acreditación esta disponible y les pedimos para una mejor coordinación en la mesa de entrada se registren de antemano: http://www.cafeconf.org/2007/modules/eguide/event.php?eid=1 -- http://mail.python.org/mailman/listinfo/python-list
Re: question about for cycle
On Sep 29, 8:19 am, George Sakkis [EMAIL PROTECTED] wrote: On Sep 29, 10:34 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: On 29 sep, 12:04, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: for i in generator_a: # the first for cycle for j in generator_b: if something_happen: # do something here ..., I want the outer cycle to break break Do you like this? generator_ab = ((x, y) for x in generator_a for y in generator_b) for i, j in generator_ab: if condition: # do something break In this case, the tuple generator_ab must be generated first. George You can get specific break points by expanding the for loop into a while loop, and this is perhaps why it has never been implemented with for loops. ctr_a=0 ctr_b=0 while ctr_a len(generator_a): this_el_a = generator_a[ctr_a] while ctr_b len(generator_b): this_el_b = generator_b[ctr_ b] if something_happen: ctr_b = len(generator_b) ## break this loop if something_else: ctr_a = len(generator_a) ## break outer while loop ctr_b += 1 ctr_a += 1 -- http://mail.python.org/mailman/listinfo/python-list
Re: C Source Code Generator For Test Cases
Instead of reading the testcase tables and generating source for test routines you simply can do the tests right away. Can't. :( This is for an embedded system. I need to create source (in C) on one machine and then compile on others. The only thing that I can be certain of is an ANSI compiler on any machine I use. -T -- http://mail.python.org/mailman/listinfo/python-list
RE: Program inefficiency?
-Original Message- From: stdazi On Sep 29, 6:07 pm, [EMAIL PROTECTED] wrote: You did not mention the OS, but because you are using pathname\editfile.txt, it sounds like you are using an MS OS. From past experience with various MS OSes, I found that as the number of files in a directory increases the slower your process runs for each file. how so? I said sounds like, which means I was guessing. In *nix ( the ones I know ), it would have been pathname/editfile.txt. But, it was the file extension that caught my eye. I had a project a while back that required a mass conversion of jpeg files and ran into what sounded like a similar problem. The information contained in this message and any attachment may be proprietary, confidential, and privileged or subject to the work product doctrine and thus protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify me immediately by replying to this message and deleting it and all copies and backups thereof. Thank you. -- http://mail.python.org/mailman/listinfo/python-list
Re: Program inefficiency?
On Sep 29, 9:32 pm, stdazi [EMAIL PROTECTED] wrote: On Sep 29, 6:07 pm, [EMAIL PROTECTED] wrote: You did not mention the OS, but because you are using pathname\editfile.txt, it sounds like you are using an MS OS. From past experience with various MS OSes, I found that as the number of files in a directory increases the slower your process runs for each file. how so? Not entirely sure why, but some of the ms docs allude to the fact that there is a linked list involved (at least for fat-style disks). -- bjorn -- http://mail.python.org/mailman/listinfo/python-list
How to unload a module after I've imported it.
Is it possible to unload a module after I've imported it. I have the main program from which I import several smaller programs. Some of these uses timeoutsocket module. But one of the smaller program can not work with the timeoutsocket module, so I must unload the timeoutsocket module, execute the program and then reload timeoutsocket module. So, s it possible to unload a module after I've imported it.. Thanks L. -- http://mail.python.org/mailman/listinfo/python-list
RE: Program inefficiency?
-Original Message- From: thebjorn On Sep 29, 9:32 pm, stdazi [EMAIL PROTECTED] wrote: On Sep 29, 6:07 pm, [EMAIL PROTECTED] wrote: You did not mention the OS, but because you are using pathname\editfile.txt, it sounds like you are using an MS OS. From past experience with various MS OSes, I found that as the number of files in a directory increases the slower your process runs for each file. how so? Not entirely sure why, but some of the ms docs allude to the fact that there is a linked list involved (at least for fat-style disks). Wow! Talk about defending one's self ( me ). I took stdazi's question to mean why I thought it was an MS OS issue. And, yes, you are correct about the linked-list. Although, I do not know if that was the reason for the my problem. The information contained in this message and any attachment may be proprietary, confidential, and privileged or subject to the work product doctrine and thus protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify me immediately by replying to this message and deleting it and all copies and backups thereof. Thank you. -- http://mail.python.org/mailman/listinfo/python-list
Re: python 2.5 and 3gb switch
Since I was last here I found someone who is willing to do a 3gb python build for me who builds Blender as well. I am pretty sure python is just not recognising the extra space. Apparently there is a python module used in the 3gb Blender build I have that may be contributing too although the script I have requires a full python install. I will see how his assistance goes. Thanks for your willing help guys. regards Neil -- http://mail.python.org/mailman/listinfo/python-list
Re: How to unload a module after I've imported it.
Have you tried a del? import socket dir() ['__builtins__', '__doc__', '__name__', 'socket'] del socket dir() ['__builtins__', '__doc__', '__name__'] See you! -- http://mail.python.org/mailman/listinfo/python-list
Command-line does work when scheduled
Hi, I want to schedule a Python program that reads the command line for input. However, when adding an argument to the command line Python will not pick it up when using Windows scheduled tasks. How do I get it to work? Thanks, Jim -- http://mail.python.org/mailman/listinfo/python-list
Re: How to unload a module after I've imported it.
En Sat, 29 Sep 2007 17:32:15 -0300, marvinla [EMAIL PROTECTED] escribi�: Have you tried a del? import socket dir() ['__builtins__', '__doc__', '__name__', 'socket'] del socket dir() ['__builtins__', '__doc__', '__name__'] py import socket py del socket py import sys py sys.modules['socket'] module 'socket' from 'c:\apps\Python25\lib\socket.pyc' del only removes the reference from the current namespace, but the module is still loaded and available. del sys.modules['socket'] would remove the module so the next import statement will have to reload it. Back to the original question, timeoutsocket replaces some objects in the socket module with its own versions, just unloading timeoutsocket would not be enough, the changes had to be reverted. timeoutsocket is an old hack for Python 2.2 and earlier. Since 2.3 you can achieve the same thing using socket.setdefaulttimeout() so unless you are forced to use such ancient versions, it can be dropped. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: question about for cycle
On 29 sep, 21:38, Zentrader [EMAIL PROTECTED] wrote: ctr_a=0 ctr_b=0 while ctr_a len(generator_a): this_el_a = generator_a[ctr_a] while ctr_b len(generator_b): this_el_b = generator_b[ctr_ b] if something_happen: ctr_b = len(generator_b) ## break this loop if something_else: ctr_a = len(generator_a) ## break outer while loop ctr_b += 1 ctr_a += 1 Mmm, isn't a bit complicated? Anyway, neither len() nor __getitem__ work on generators. -- http://mail.python.org/mailman/listinfo/python-list
Re: Command-line does work when scheduled
En Sat, 29 Sep 2007 17:34:34 -0300, Jim [EMAIL PROTECTED] escribi�: I want to schedule a Python program that reads the command line for input. However, when adding an argument to the command line Python will not pick it up when using Windows scheduled tasks. How do I get it to work? Do you write the command line when defining the task? Using double quotes around arguments with spaces? It works fine for me. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: List search
Kevin Walzer wrote: I'm having a problem with searching a list. Here's my code: mylist = ['x11', 'x11-wm', 'x11-system'] for line in mylist: if 'x11' in line: print line This results in the following output: x11 x11-wm x11-system I'm looking to return the list item that just has 'x11'. Why do you want to have an item you already know? If you just wanted to check *if* the string x11 is in the list, you'd use if x11 in mylist: Regards, Björn -- BOFH excuse #221: The mainframe needs to rest. It's getting old, you know. -- http://mail.python.org/mailman/listinfo/python-list
Re: Command-line does work when scheduled
On Sep 29, 3:19 pm, Gabriel Genellina [EMAIL PROTECTED] wrote: En Sat, 29 Sep 2007 17:34:34 -0300, Jim [EMAIL PROTECTED] escribi?: I want to schedule a Python program that reads the command line for input. However, when adding an argument to the command line Python will not pick it up when using Windows scheduled tasks. How do I get it to work? Do you write the command line when defining the task? Using double quotes around arguments with spaces? It works fine for me. -- Gabriel Genellina I ran the following on the Scheduled Tasks: J:\Jim Crerar\MyPython\Zero_OE_Counter\Zero_OE_Counter.py n J:\Jim Crerar\MyPython\Zero_OE_Counter\Zero_OE_Counter.py n J:\Jim Crerar\MyPython\Zero_OE_Counter\Zero_OE_Counter.py n None of them work. However, no problem with running from *.bat file or directly from shortcut on my Desktop. Thanks, Jim -- http://mail.python.org/mailman/listinfo/python-list
Re: Program inefficiency?
On Sep 29, 2:32 pm, [EMAIL PROTECTED] wrote: It think he's saying it should look like this: (line noise snipped) Or you can let BeautifulSoup do the dirty job for you and forget all this ugliness: from BeautifulSoup import BeautifulSoup soup = BeautifulSoup(text) for a in soup.findAll('a'): for attr in 'href','name': val = a.get(attr) if val: a[attr] = val.replace(' ','_') print soup George -- http://mail.python.org/mailman/listinfo/python-list
What's the current status of socket timeouts?
What actually works and what doesn't in socket timeouts in Python 2.5? What breaks with timeouts turned on? There are lots of patches and bug reports, but no coherent summary. John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: Program inefficiency?
thebjorn wrote: On Sep 29, 7:55 pm, Pablo Ziliani [EMAIL PROTECTED] wrote: thebjorn wrote: Ugh, that was entirely too many regexps for my taste :-) Oh yeah, now it's clear as mud. I'm anxiously awaiting your beacon of clarity ;-) Admittedly, that was a bit arrogant from my part. Sorry. I do think that the whole program shouldn't take more than 10 lines of code Well, my mass_replace above is 10 lines, and the actual replacement code is a one liner. Perhaps you'd care to illustrate how you'd shorten that while still keeping it clear? I don't think he relevant code was only those 10 lines, but well, you have already responded to the other question yourself in a subsequent post (thanks for saving me a lot of time). I think that clear is a compromise between code legibility (most of what you sacrifice using regexes) and overall code length. Even regexes can be legible enough when they are well documented, not to mention the fact that is an idiom common to various languages. using one sensible regex I have no doubt that it would be possible to do with a single regex. Whether it would be sensible or not is another matter entirely... Putting it in those terms, I completely agree with you (that's why I suggested letting e.g. BeautifulSoup deal with them). But by sensible I meant something different, inherent to the regex itself. For instance, I don't think I need to explain to you why this is not sensible: (href=|HREF=)+(.*)(#)+(.*)(\w\'\?-:)+(.*)()+ (impossible to define without knowing the real input and output formats). Of course, but I don't think you can guess too terribly wrong. My version handles upper and lower case attributes, quoting with single (') and double () quotes, and any number of spaces in attribute values. It maintains all other text as-is, and converts spaces to underscores in href and name attributes. Did I get anything majorly wrong? Well, you spent some time interpreting his code. No doubt you are smart, but being a lazy person (not proud of that, unlike other people stating the same) I prefer leaving that part to the interested party. And (sorry to tell) I'm convinced this is a problem for regexes, in spite of anybody's personal taste. Well, let's see it then :-) IMO, your second example proves it well enough. FWIW I did some changes to your code (see attached), because it wasn't taking into account the tag name (a), and the names of the attributes (href, name) can appear in other tags as well, so it's a problem. It still doesn't solve the problem of one tag having both attributes with spaces (which can be easily fixed with a second regex, but that was out of question :P), and there can be a lot of other problems (both because I'm far from being an expert in regexes and because I only tested it against the given string), but should provide at least some guidance. I made it also match the id of the target anchor, since a fragment can point both to its name or its id, depending on the doctype. Regards, Pablo import re tests = a href=Web_Sites.htm#A Web Sitesbase case/a a id=invalid idnot a link/a a id=valid-idstill, not a link/a a name=A Web Sitessome text/a a href=Web_Sites.htm#A Web Siteszzz /a a rel=external href=Web_Sites.htm#A Web Sitesother attributes/a a name=A Web Sitestwo in a row/aa name=Web-sites/a a href=Web_Sites.htm#A Web Sites name=A Web Sitesboth attributes/a a href=Web_Sites.htm#A Web Sites name=A Web Sites id=valid-idall three attributes/a input name=should not change / link href=should not change/ pattern = r'''a\b(?Ppreamble[^]*?) (?: href=['](?Ppage[^#]*)[#](?Pfragment[^']+)['] | (?Ptargetname|id)=(?Ptargetvalue ['][^']+['] | [^\s]+ ) )''' regex = re.compile(pattern, re.IGNORECASE | re.MULTILINE | re.VERBOSE) to_replace = re.compile([^\w\'-]) #replaces everything but letters, hyphens and quotes def replace(match): groups = match.groupdict() result = a%(preamble)s if groups['fragment']: result += ('href=%%(page)s#%s' % to_replace.sub('_', groups['fragment'])) if groups['targetvalue']: result += '%%(target)s=%s' % to_replace.sub('_', groups['targetvalue']) return result % groups print regex.sub(replace, tests)-- http://mail.python.org/mailman/listinfo/python-list
All Quick Test Professional (QTP) FAQs
All Quick Test Professional (QTP) FAQs QuickTest Professional (QTP) Questions and Answers Part # 1 http://softwareqatestings.com/content/view/188/38/ QuickTest Professional (QTP) Questions and Answers Part # 2 http://softwareqatestings.com/content/view/189/38/ QuickTest Professional (QTP) Questions and Answers Part # 3 http://softwareqatestings.com/content/view/190/38/ QuickTest Professional (QTP) Questions and Answers Part # 4 http://softwareqatestings.com/content/view/191/38/ QuickTest Professional (QTP) Questions and Answers Part # 5 http://softwareqatestings.com/content/view/192/38/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Optparse and help formatting?
Tim Chase [EMAIL PROTECTED] writes: I've been learning the ropes of the optparse module and have been having some trouble getting the help to format the way I want. A quick perusal of the 'optparse.py' code shows me this: [...] class OptionParser([...]): def __init__([...], formatter=None, [...]): [...] if formatter is None: formatter = IndentedHelpFormatter() [...] So, the OptionParser init method accepts the help formatter as the 'formatter' argument, defaulting to a new instance of IndentedHelpFormatter. Presumably, it's a matter of subclassing 'optparse.HelpFormatter' and overriding the behaviour you want to change, then passing an instance of your new class as the 'formatter' argument to the 'OptionParser()' invocation. -- \Members of the general public commonly find copyright rules | `\ implausible, and simply disbelieve them. -- Jessica Litman, | _o__) _Digital Copyright_ | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: getopt with negative numbers?
Carl Banks [EMAIL PROTECTED] writes: On Sep 28, 6:19 pm, Ben Finney [EMAIL PROTECTED] wrote: Steven Bethard [EMAIL PROTECTED] writes: A user shouldn't have to go out of their way to specify regular numbers on the command line, regardless of whether they're positive or negative. A user shouldn't have to go out of their way to know whether what they type on a command line will be treated as an option or an argument. I guess typing ./program --help is out of the question. You're trying to have it both ways. You're saying the user shouldn't have to go out of their way to type arbitrary arguments on the command line. Then, in your next message, you suggest they must *read the detailed command-line help* in order to know whether they *can* type arbitrary command-line arguments. Is learn about how the program expects options and arguments within your definition of go out of their way, or isn't it? If it's not, then shouldn't have to go out of their way is *not* an argument in favour of special-casing negative-numbers. -- \ We spend the first twelve months of our children's lives | `\ teaching them to walk and talk and the next twelve years | _o__)telling them to sit down and shut up. -- Phyllis Diller | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: New to python
On Sat, 29 Sep 2007 21:20:10 -0700, Googy wrote: I am new to python... The programming language i know well is C Can any one recommend me the good ebook for beginners. I have loads of ebooks but i am not able to decide which to start with which book. Also i am learning XML so later on i can switch to books on Python and XML but initially which book to read?? Please help... Generically, `A byte of Python`_ and `Dive into Python`_ are pretty common. ABOP has a few comments for C programmers as well, AFAIK. If you already got a few (e)books, you should perhaps just look through all of them and then, sequentially, read them. .. _A byte of Python: http://www.byteofpython.info/download/ .. _Dive into Python: http://www.diveintopython.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: New to python
On Sat, 29 Sep 2007 21:20:10 -0700, Googy wrote: I am new to python... The programming language i know well is C Can any one recommend me the good ebook for beginners. I have loads of ebooks but i am not able to decide which to start with which book. Also i am learning XML so later on i can switch to books on Python and XML but initially which book to read?? Please help... Some years ago I crossed over from C to Python myself. I found Python weird and incomprehensible at first, especially since I was effectively having to learn OO at the same time. I worked through the standard Python tutorial that comes with the Python manual, and kept an interactive Python interpreter session running in a terminal. It was tough for a while, but before long, something just seemed to 'click' and I 'got it'. There were still many things to learn - I'm still learning - but what has helped heaps has been the #python IRC channel on irc.freenode.net. Keep at it - it'll gel for you if you persist, and you're willing to do lots of experimenting. -- http://mail.python.org/mailman/listinfo/python-list
Re: HOT!!!PYTHON DEVELOPER REQUIRED @ ADOBE SYSTEMS
THANKS for introducing me to Python applets. Applications -- Applets -- Apploids -- Applcainers -- ... -- Approcities Sorry, couldn't resist. On 9/27/07, Recruiter-Adobe [EMAIL PROTECTED] wrote: Hi PYTHON DEVELOPERS, ADOBE SYSTEMS is looking for a PYTHON DEVELOPER who can troubleshoot Python based applet which makes data base queries and populates Excel tables used to generate pivot charts, graphs and tables showing bug metrics. Isolate problem which is causing reports to crash and institute fix. This is a position through Manpower at our customer Adobe Systems, you will be employed as a Manpower's contractor. Job Responsibilities: · Setup a new server (development environment) · Install updated versions of both python and other plugins used for our applet. · Import Code/applet instance. · Remove code that uploads it to the Production Server Instance · Eventually move the entire Production Instance over to the newer server. · Update Code to comply with the latest Python standards Knowledge Skills: · Expert in Python Programming · Experience in COM Object programming speficially Excel COM Objects · Experience in using WebServices (SOAP) · Win2k System Administration Experience a Plus · Need to migrate from version 2.3 to latest version of Python Hourly Pay rate: $85-$100/hr If interested, please send a Word copy of your resumeto [EMAIL PROTECTED] with your expected hourly rate, availability, visa status, best time and phone # to contact you. -- http://mail.python.org/mailman/listinfo/python-list -- Regards, Arvind -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple threading example freezes IDLE?
idle doesn't work well with threads On 9/27/07, 7stud [EMAIL PROTECTED] wrote: On Sep 26, 5:01 pm, Sergio Correia [EMAIL PROTECTED] wrote: I'm using IDLE 1.2.1, Python 2.5.1, and Tk 8.4. Does anyone has any idea of why is this happening? Two mainloops == bad. IDLE == 1 mainloop. your program == 1 mainloop. -- http://mail.python.org/mailman/listinfo/python-list -- http://www.goldwatches.com/mens/cufflinks.html http://www.jewelerslounge.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Command-line does work when scheduled
En Sat, 29 Sep 2007 22:04:06 -0300, Jim [EMAIL PROTECTED] escribi�: If it works this way, maybe the .py file extension is not correctly registered. Yes, it works this way. How do I register the .py extension correctly? From a command line, type: assoc .py You should get: .py=Python.File If you get an error, or another thing like py_auto_file: assoc .py=Python.File Then: ftype Python.File You should get: Python.File=c:\path\to\python.exe %1 %* If you don't: ftype Python.File=c:\path\to\python.exe %1 %* The %* at the end is important: if you created the association by using Open with..., or selecting Python from the list of installed programs, very likely the command says only %1 - that is, the script being open, but without any additional arguments. Better if you have administrative rights to do this tasks. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
ANN: y4m - Python video editing framework
Hi all, Just a quick message to announce the latest release (v0.1.1) of the 'y4m' framework. www.freenet.org.nz/y4m What is 'y4m'? y4m is a python framework for manipulating yuv4mpeg video streams. Young but growing rapidly. It offers an intuitive Python API for: - opening yuv4mpeg streams for reading from stdin or a file (or auto-converting from any other video format ffmpeg can cope with) - opening yuv4mpeg streams for writing to stdout or a file (or autoconverting to any other video format ffmpeg can handle) - reading/changing stream and frame attributes - manipulating frames at any level - as rows/columns, or as pixels, or as Y,Cb,Cr planes - performing basic editing operations, such as: - scaling - cropping - clipping (eg taking 15 secs of a stream after the first minute) - flipping - overlaying - cross-fading (also known as 'dissolve') - transparency - polygon fill - arbitrary rotation - simple keyframe interpolation It also features a plugin architecture, whereby you can overcome the performance penalties of python by invoking fast plugins written in C. The plugin interface offers a simple and powerful framework to support writing your own plugins easily, and comes with several working example plugins). y4m is a toolkit you can use for writing your own yuv4mpeg stdio filters, or even building your own video editing software. y4m is still in alpha, but works quite well on 32-bit architecture. (I can't guarantee it on 64-bit just yet - at least not till I've pulled out all the remaining (sizeof)int==(sizeof)(*) assumptions. Anyone with 64-bit architecture is welcome to try it - I'd love to hear how you get on with it.) All feedback, suggestions, patches, bouquets, brickbats etc welcome. Cheers David -- http://mail.python.org/mailman/listinfo/python-list
Re: getopt with negative numbers?
On Sep 29, 7:58 pm, Ben Finney [EMAIL PROTECTED] wrote: Carl Banks [EMAIL PROTECTED] writes: On Sep 28, 6:19 pm, Ben Finney [EMAIL PROTECTED] wrote: Steven Bethard [EMAIL PROTECTED] writes: A user shouldn't have to go out of their way to specify regular numbers on the command line, regardless of whether they're positive or negative. A user shouldn't have to go out of their way to know whether what they type on a command line will be treated as an option or an argument. I guess typing ./program --help is out of the question. You're trying to have it both ways. You're saying the user shouldn't have to go out of their way to type arbitrary arguments on the command line. No, I'm not. Don't put words in my mouth. I don't think it's going out of your way to read the documentation, or to put a couple hyphens on the line. Those were your words, and they were an utterly silly hyperbole. Then, in your next message, you suggest they must *read the detailed command-line help* in order to know whether they *can* type arbitrary command-line arguments. You're writing a program that takes numerical positional arguments. Are you being more of asshole ir you A. Expect me to read the documentation, or B. Force me to type two hyphens every single time I want to enter a negative number? I would say B by a mile. Not that it's going out of my way to enter the extra hyphens; it's just irritating and completely, totally, and utterly unnecessary. Is learn about how the program expects options and arguments within your definition of go out of their way, or isn't it? If it's not, then shouldn't have to go out of their way is *not* an argument in favour of special-casing negative-numbers. It's only a special case in your imagination. Try typing this: seq -9 -1 On my system, seq is a GNU tool, and the guys at the FSF are some of the biggest tightwads around when it comes to command line options. Even when they allow nonconformant options for the sake of backwards compatibility, they run a guilt trip on you. But even they see the practicality in allowing negative number arguments in some cases. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: Command-line does work when scheduled
En Sat, 29 Sep 2007 19:17:49 -0300, Jim [EMAIL PROTECTED] escribi�: On Sep 29, 3:19 pm, Gabriel Genellina [EMAIL PROTECTED] wrote: En Sat, 29 Sep 2007 17:34:34 -0300, Jim [EMAIL PROTECTED] escribi?: I want to schedule a Python program that reads the command line for input. However, when adding an argument to the command line Python will not pick it up when using Windows scheduled tasks. How do I get it to work? Do you write the command line when defining the task? Using double quotes around arguments with spaces? It works fine for me. I ran the following on the Scheduled Tasks: J:\Jim Crerar\MyPython\Zero_OE_Counter\Zero_OE_Counter.py n J:\Jim Crerar\MyPython\Zero_OE_Counter\Zero_OE_Counter.py n J:\Jim Crerar\MyPython\Zero_OE_Counter\Zero_OE_Counter.py n None of them work. However, no problem with running from *.bat file or directly from shortcut on my Desktop. Try prepending the Python executable: C:\Python25\Python.exe J:\Jim Crerar\MyPython\Zero_OE_Counter\Zero_OE_Counter.py n If it works this way, maybe the .py file extension is not correctly registered. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Command-line does work when scheduled
On Sep 29, 6:56 pm, Gabriel Genellina [EMAIL PROTECTED] wrote: En Sat, 29 Sep 2007 19:17:49 -0300, Jim [EMAIL PROTECTED] escribi?: On Sep 29, 3:19 pm, Gabriel Genellina [EMAIL PROTECTED] wrote: En Sat, 29 Sep 2007 17:34:34 -0300, Jim [EMAIL PROTECTED] escribi?: I want to schedule a Python program that reads the command line for input. However, when adding an argument to the command line Python will not pick it up when using Windows scheduled tasks. How do I get it to work? Do you write the command line when defining the task? Using double quotes around arguments with spaces? It works fine for me. I ran the following on the Scheduled Tasks: J:\Jim Crerar\MyPython\Zero_OE_Counter\Zero_OE_Counter.py n J:\Jim Crerar\MyPython\Zero_OE_Counter\Zero_OE_Counter.py n J:\Jim Crerar\MyPython\Zero_OE_Counter\Zero_OE_Counter.py n None of them work. However, no problem with running from *.bat file or directly from shortcut on my Desktop. Try prepending the Python executable: C:\Python25\Python.exe J:\Jim Crerar\MyPython\Zero_OE_Counter\Zero_OE_Counter.py n If it works this way, maybe the .py file extension is not correctly registered. -- Gabriel Genellina- Hide quoted text - - Show quoted text - Yes, it works this way. How do I register the .py extension correctly? Thanks, Jim -- http://mail.python.org/mailman/listinfo/python-list
Re: Balloon Taskbar Popup for Windows XP
En Sat, 29 Sep 2007 07:40:21 -0300, makko [EMAIL PROTECTED] escribi�: I need to create a function that will produce a balloon popup in the taskbar when called. Whats the shortest and easiest way to do this? Mark Hammond's pywin32 extensions support notification icons but not balloon popups. The Windows NOTIFYICONDATA structure in newer shell versions contains more fields, required to show a balloon tooltip, but it is incompatible with earlier versions (there are dumb people in MS too...) Below there is a demo based on win32gui_taskbar.py, using pywin32, ctypes and struct. The bulk of code is just to create the window, setup the menu, and such. The balloon is shown on this fragment: def show_balloon(self): # For this message I can't use the win32gui structure because # it doesn't declare the new, required fields nid = PyNOTIFYICONDATA() nid.hWnd = self.hwnd nid.uFlags = NIF_INFO # type of balloon and text are random from random import choice nid.dwInfoFlags = choice([NIIF_INFO, NIIF_WARNING, NIIF_ERROR]) nid.szInfo = choice([Balloon text., This text is nicer., Perl rulez! :)]) nid.szInfoTitle = A Title # Call the Windows function, not the wrapped one from ctypes import windll Shell_NotifyIcon = windll.shell32.Shell_NotifyIconA Shell_NotifyIcon(NIM_MODIFY, nid.pack()) For more info see the Shell_NotifyIcon docs at http://msdn2.microsoft.com/en-us/library/ms647738.aspx code # Based on win32gui_taskbar demo from win32api import * # Try and use XP features, so we get alpha-blending etc. try: from winxpgui import * except ImportError: from win32gui import * import win32con import sys, os import struct import timer class PyNOTIFYICONDATA: _struct_format = ( I # DWORD cbSize; I # HWND hWnd; I # UINT uID; I # UINT uFlags; I # UINT uCallbackMessage; I # HICON hIcon; 128s #TCHAR szTip[128]; I # DWORD dwState; I # DWORD dwStateMask; 256s # TCHAR szInfo[256]; I # union { #UINT uTimeout; #UINT uVersion; #} DUMMYUNIONNAME; 64s #TCHAR szInfoTitle[64]; I # DWORD dwInfoFlags; # GUID guidItem; ) _struct = struct.Struct(_struct_format) hWnd = 0 uID = 0 uFlags = 0 uCallbackMessage = 0 hIcon = 0 szTip = '' dwState = 0 dwStateMask = 0 szInfo = '' uTimeoutOrVersion = 0 szInfoTitle = '' dwInfoFlags = 0 def pack(self): return self._struct.pack( self._struct.size, self.hWnd, self.uID, self.uFlags, self.uCallbackMessage, self.hIcon, self.szTip, self.dwState, self.dwStateMask, self.szInfo, self.uTimeoutOrVersion, self.szInfoTitle, self.dwInfoFlags) def __setattr__(self, name, value): # avoid wrong field names if not hasattr(self, name): raise NameError, name self.__dict__[name] = value class MainWindow: def __init__(self): message_map = { win32con.WM_DESTROY: self.OnDestroy, win32con.WM_COMMAND: self.OnCommand, win32con.WM_USER+20: self.OnTaskbarNotify, } # Register the Window class. wc = WNDCLASS() hinst = wc.hInstance = GetModuleHandle(None) wc.lpszClassName = PythonTaskbarDemo wc.lpfnWndProc = message_map # could also specify a wndproc. classAtom = RegisterClass(wc) # Create the Window. style = win32con.WS_OVERLAPPED | win32con.WS_SYSMENU self.hwnd = CreateWindow( classAtom, Taskbar Demo, style, \ 0, 0, win32con.CW_USEDEFAULT, win32con.CW_USEDEFAULT, \ 0, 0, hinst, None) UpdateWindow(self.hwnd) iconPathName = os.path.abspath(os.path.join( sys.prefix, pyc.ico )) icon_flags = win32con.LR_LOADFROMFILE | win32con.LR_DEFAULTSIZE try: hicon = LoadImage(hinst, iconPathName, win32con.IMAGE_ICON, 0, 0, icon_flags) except: hicon = LoadIcon(0, win32con.IDI_APPLICATION) flags = NIF_ICON | NIF_MESSAGE | NIF_TIP nid = (self.hwnd, 0, flags, win32con.WM_USER+20, hicon, Balloon tooltip demo) Shell_NotifyIcon(NIM_ADD, nid) print Ready. Click on the Python icon. def OnTaskbarNotify(self, hwnd, msg, wparam, lparam): if lparam==win32con.WM_LBUTTONUP or lparam==win32con.WM_RBUTTONUP: print Click. menu = CreatePopupMenu() AppendMenu( menu, win32con.MF_STRING, 1024, Generate balloon) AppendMenu( menu, win32con.MF_STRING, 1025, Exit) pos =
earn $26800 a month with google adsense
www.space666.com sport news and make money -- http://mail.python.org/mailman/listinfo/python-list
Optparse and help formatting?
I've been learning the ropes of the optparse module and have been having some trouble getting the help to format the way I want. I want to specify parts of an option's help as multiline. However, the optparse formatter seems to eat newlines despite my inability to find anything in optparse.py that does something obvious like .replace(\n, ) to eat the newlines I stick in the help. It also seems to mung tabs. An example from my code: parser.add_option(-x, --extended, action=callback, callback=callback_test, type=string, # required to get metavar to show in help dest=test, metavar=CONF, help=a comma-separated list of options.\n s=[]MMDD,n=NAME,c=COLOR\n s,start=[]MMDD\n \tstart day of period (default, current day)\n ... ) which would accept options that looked something like test.py -x s=20070401,n=XR71,c=black (my callback_test breaks apart parser.rargs[0] to deal with the funky params). However, when I display the help, its reformatting eats the newlines in my help-string and strangely looks like it converts my tabs to spaces. Any hints on how to either work around the problem or fix it? As a side note, I couldn't find documented anywhere that if you have a metavar setting for a callback parameter, you have to specify the type to get the metavar to show up in the help as -x CONF, --extended=CONF. If you don't specify the type, it will display as -x, --extended without the metavar, even if you specify one. Hackishly setting type=string made the metavar appear. Thanks for any hints, -tkc (python2.4 on Debian, FWIW) -- http://mail.python.org/mailman/listinfo/python-list
Re: HOT!!!PYTHON DEVELOPER REQUIRED @ ADOBE SYSTEMS
Spam! On 9/27/07, Recruiter-Adobe [EMAIL PROTECTED] wrote: Hi PYTHON DEVELOPERS, ADOBE SYSTEMS is looking for a PYTHON DEVELOPER who can troubleshoot Python based applet which makes data base queries and populates Excel tables used to generate pivot charts, graphs and tables showing bug metrics. Isolate problem which is causing reports to crash and institute fix. This is a position through Manpower at our customer Adobe Systems, you will be employed as a Manpower's contractor. Job Responsibilities: · Setup a new server (development environment) · Install updated versions of both python and other plugins used for our applet. · Import Code/applet instance. · Remove code that uploads it to the Production Server Instance · Eventually move the entire Production Instance over to the newer server. · Update Code to comply with the latest Python standards Knowledge Skills: · Expert in Python Programming · Experience in COM Object programming speficially Excel COM Objects · Experience in using WebServices (SOAP) · Win2k System Administration Experience a Plus · Need to migrate from version 2.3 to latest version of Python Hourly Pay rate: $85-$100/hr If interested, please send a Word copy of your resumeto [EMAIL PROTECTED] with your expected hourly rate, availability, visa status, best time and phone # to contact you. -- http://mail.python.org/mailman/listinfo/python-list -- http://www.goldwatches.com/mens/cufflinks.html http://www.jewelerslounge.com -- http://mail.python.org/mailman/listinfo/python-list