Re: graphical or flow charting design aid for python class development?
It's not free, but it is pretty cheap considering all it can do. Check out Enterprise Architect (with the free add-in for Python) from www.sparxsystems.com.au. Pro version license is US$180 or so, but they may have a student license for less that you could use. -- Paul -- http://mail.python.org/mailman/listinfo/python-list
Python 2.4 decompiler
A brand new python 2.4 bytecode decompiler has been released. The compiling service is now available and includes features to check the correctness of the output. Those who need the service can contact us at [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Well, Python is hard to learn...
due to the work reason, i have to learn python since last month. i have spent 1 week on learning python tutorial and felt good. but i still don't understand most part of sourcecode of PYMOL(http://pymol.sourceforge.net/) as before. it sucks. anybody do the same thing as i am doing? i wanna seek a buddy to disscuss it together. -- http://mail.python.org/mailman/listinfo/python-list
cgi, reusing html. common problem?
I'm putting together a small site using Python and cgi. (I'm pretty new to this, but I've worked a little with JSP/servlets/Java before.) Almost all pages on the site will share some common (and static) html, however, they'll also have dynamic aspects. I'm guessing that the common way to build sites like this is to have every page (which contains active content) be generated by a cgi script, but also have some text files hanging around containing incomplete html fragments which you read and paste-in as-needed (I'm thinking: header.html.txt, footer.html.txt, and so on). Is that how it's usually done? If not, what *is* the usual way of handling this? Thanks, ---John -- --- if contacting via email, remove zees --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Adding bound methods dynamically... CORRECTED
> > Yes, but rather than going through the contortions you do to bind a > new method into place, why not make the method in question act as a > proxy for the real method? After all, with first-class functions, > that's easy. Because you don't have to write that proxy. Pure lazyness :) Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Yielding a chain of values
This is why my original proposal used the '*' operator rather than a keyword. The reasoning behind this is as follows: When calling a function, a parameter of the form "*expression" expands to a list of arguments. From the Python reference manual: "If the syntax '*expression' appears in the function call, 'expression' must evaluate to a sequence. Elements from this sequence are treated as if they were additional positional arguments." By (somewhat stretched) analogy, "yield *expression" would "expand" the sequence into a series of multiple yields. Of course, now that yield is an expression (as stated above), you would indeed have to account for the fact that the yield statement used in this way would yield a sequence of values: for x in yield *[ 1, 2, 3 ]: print x So the '*' would not only signal that multiple values were being yielded, but that multiple values are also being returned. -- Talin -- http://mail.python.org/mailman/listinfo/python-list
Re: cgi, reusing html. common problem?
John M. Gabriele wrote: > I'm putting together a small site using Python and cgi. > > (I'm pretty new to this, but I've worked a little with > JSP/servlets/Java before.) > > Almost all pages on the site will share some common (and > static) html, however, they'll also have dynamic aspects. > I'm guessing that the common way to build sites like this > is to have every page (which contains active content) be > generated by a cgi script, but also have some text files > hanging around containing incomplete html fragments which > you read and paste-in as-needed (I'm thinking: > header.html.txt, footer.html.txt, and so on). > > Is that how it's usually done? If not, what *is* the > usual way of handling this? The basic idea is correct - but there are sooo many other people that had the same problem, and thus they creted web-framworks like e.g. CherryPy or Django or... and then there is ZOPE. Search this group for webframeworks, and you might get more answers than you wanted :) Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Well, Python is hard to learn...
I don't know about you but I would not learn ANY decent programming language for a week and expect to know the idioms enough to understand the source of a large software written in it. -- http://mail.python.org/mailman/listinfo/python-list
Re: OpenSource documentation problems
Fredrik Lundh wrote: > Bryan Olson wrote: >> import pydoc >> help is pydoc.help >> > >> > False >> >>Say Fredrik, if you're going to proclaim "False" > > oh, I didn't proclaim anything. Python 2.4 did. False. ;) That was all you. > let's see what > Python 2.2 has to say about this: > > $ python2.2 > Python 2.2.1 (#2, Jul 17 2002, 13:11:01) > [GCC 2.96 2731 (Red Hat Linux 7.1 2.96-98)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > import pydoc help is pydoc.help > > 0 You might look at what Mr. Kutching actually wrote: help *is* pydoc.help, or at least a trivial wrapper around it or how I quoted that: Since "help *is* pydoc.help, or at least...", the call could Missed that 'or' did you? Since 'or' is a Python keyword, let's follow your procedure, and see if Python (the current version this time) can clue us in as to what it means. >>> help('or') Sorry, topic and keyword documentation is not available because the Python HTML documentation files could not be found. If you have installed them, please set the environment variable PYTHONDOCS to indicate their location. Darn. I just did the standard Windows install, so I kinda hoped it would set things up the way it needs them. Oh, well I'll push on and set the environment variable. Hmmm... no joy. Same message. What's going on? Well, let's look up the pydoc module. http://docs.python.org/lib/module-pydoc.html Module docs for core modules are assumed to reside in http://www.python.org/doc/current/lib/. This can be overridden by setting the PYTHONDOCS environment variable to a different URL or to a local directory containing the Library Reference Manual pages. Odd, it looks like setting the PYTHONDOCS variable isn't even supposed to be required. O.K. Next the source: ; Ah, problem in pydoc.Helper.__init__: for dir in [os.environ.get('PYTHONDOCS'), homedir and os.path.join(homedir, 'doc'), os.path.join(execdir, 'doc'), '/usr/doc/python-docs-' + split(sys.version)[0], '/usr/doc/python-' + split(sys.version)[0], '/usr/doc/python-docs-' + sys.version[:3], '/usr/doc/python-' + sys.version[:3], os.path.join(sys.prefix, 'Resources/English.lproj/Documentation')]: if dir and os.path.isdir(os.path.join(dir, 'lib')): self.docdir = dir Obviously that's not going to find the URL. Still, it looks like it's trying to find the doc/ directory in the PYTHONDOCS environment variable. I'm not sure why it's looking for 'lib' as a subdirectory when the pydoc documentation said to set the environment variable to the directory with the library doc. (Also, I can't quite fathom why the loop goes on searching after it finds what it seem to be looking for.) Next thing to check is whether the doc/ directory has a 'lib/' subdirectory as the code seems to expect. Aha: no such subdirectory. On the Windows install, doc/ contains one file: 'Python24.chm' and no subdirectories. Probably one of those out- of-sync change issues. I submitted the bug report at Sourceforge. > I do, however, find it a bit funny when someone reads > > Type "help", "copyright", "credits" or "license" for more information. > > as > > Type "help(help)" /.../ > > and then starts ranting about how "help(help)" isn't quite as helpful > as "help" (or "help()", for that matter -- which is what a plain "help" > tells you to use). Is it your baby that's ugly this time? Sorry, but snipping and pretending people said what they didn't is a low-class move. > it's a little like the people who type "google" into the google search > field, and then complain that the "I feel lucky" button doesn't seem > to work. Googling Google works fine. Python's doc, not so much. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list
'isa' keyword
Although I realize the perils of even suggesting polluting the Python namespace with a new keyword, I often think that it would be useful to consider defining an operator for testing whether or not an item is a member of a category. Currently, we have the 'in' operator, which tests for membership within a container, and that works very well -- in particular, it allows such membership tests to be expressed in very natural way. So for example, whereas in C++ I always have to say: if (dependencies.find( name ) != dependencies.end()) in Python I can simply say: if name in dependencies: ...which is much more readable and intuitive. At the same time, however, I recognize that there is a logical difference between membership in a container, and membership in a category. For example, although a bear is a member of the class of mammals, it doesn't make as much to say "if bear in mammal". Similarly, you wouldn't want to use the 'in' keyword as a replacement for isinstance(), i.e. "if name in str". I propose the word 'isa' because the term 'isa hierarchy' is commonly used to indicate a tree of types. So the syntax would look like this: if bear isa mammal: if name isa str: (I suppose it would look prettier to put a space between "is" and "a", but there are many obvious reasons why you don't want "a" to be a keyword!) The "isa" operator would of course be overloadable, perhaps by an accessor functions called __isa__, which works similarly to __contains__. The potential uses for this are not limited to isinstance() sugar, however. For example: if image isa gif: elif image isa jpeg: elif image isa png: In this case, we're not testing for object identity (which tests if two variables are referring to the same object), or even object equivalence (which tests of two objects are of equal value), nor are we testing for membership within a container -- instead we're testing for membership with a type hierarchy, where 'type' can be defined to mean whatever the programmer wants. Of course, at this point, I am sure that someone will point out that I should be using method overloading and inheritance rather than explicit testing of types. However, try writing an efficient __cmp__ function solely by method overloading -- or any other function that deals with more two object argument, where the action to be taken depends on the combination of types of both arguments. This can be solved with multi-method dispatch, but such methods are complex, non-standard, and have somewhat dubious performance characteristics. Its generally faster and simpler to dispatch based on the type of one of the arguments, and then test the types of the other arguments. -- http://mail.python.org/mailman/listinfo/python-list
Re: 'isa' keyword
"talin at acm dot org" <[EMAIL PROTECTED]> writes: > membership within a container -- instead we're testing for membership > with a type hierarchy, where 'type' can be defined to mean whatever the > programmer wants. Well, if "type" means a (possibly infinite) set of objects, then you can use "in". E.g, "3 in int". -- http://mail.python.org/mailman/listinfo/python-list
Re: Epydoc - Documenting class members?
Hello Terry, [Miki] >> Is there a way to document class members in Epydoc? [Terry] > Yes. See additions below: > > > Something like: > > > > class Point: > """ > @ivar x: This is where you document x. > @ivar y: This is where you document y. > """ I don't like this, I want to document where I declare the variable below. Doxygen (www.doxygen.org), for one example, knows how to do this. > > def __init__(self, x, y): > > '''Create new point > > @param x: X coord > > @param y: Y coord > > ''' > > self.x = x # How do I document here? > > self.y = y # How do I document here? > All of the fields are documented on the http://epydoc.sf.net > website, by the way. I know. Thanks. -- Miki Tebeka <[EMAIL PROTECTED]> http://tebeka.bizhat.com The only difference between children and adults is the price of the toys pgpMzSI8tF1XJ.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
Extended Language c++ in pyhton
I found serveral tool for using C++ as extended languate in python - but what's the best / easiest to use? With C I used wrappy - not sure if it's the wright name, it's included since Python 1.6 and it ist pretty ease to use. You know an example with this util for C++ or isn't it possible for C++. Would be nice to get your opinion. thx -- http://mail.python.org/mailman/listinfo/python-list
Re: Considering moving from PowerBuilder to Python
Norm Goertzen wrote: > I've posted a previous question about IDEs [...] Python is a fine scripting language; it isn't centered on a particular IDE, and doesn't really serve the same market as Powerbuilder. Building an app in Python is a far lower-level process than building one in Powerbuilder, and Powerbuilder's mastery of databases is unmatched by anything available for Python. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list
Re: command line arguments
>What's the purpose of this utility? Is it to do something with the URL? >And the URL must always be specified? What about the name? Also >mandatory, or optional? The relationship between the two? its just a simple rss reader. i'm writing it almost purely just to get me using language (i'm learning python) it lets you save rss feeds, and to do this one would specify a name and url (ie you have to specify both), but there are other things it can do (remove a rss feed, view a feed) hence i thought it was best to using command line options >You also could opt for the OptionParser in optparse.. Thanks, i'll take a look On 8/31/05, Michael Hoffman <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > > py>parser.add_option("-n", "--name", dest="name", action="store", > > py> help="enter a name") > > py>parser.add_option("-u", "--url", action="store", dest="url", > > help = "enter an url") > > It's worth noting that this will have the same effect and involves less > repetitive typing: > > parser.add_option("-n", "--name", help="enter a name") > parser.add_option("-u", "--url", help="enter a url") > > Discovering this has made optparse usage much more painless for me, and > also reduces the incidence of those nasty multiple line option additions. > > Although I should note for the record that I agree with Peter Hansen > that if the arguments are not *optional* then they should not be made > options in this manner. > -- > Michael Hoffman > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: Improving my text processing script
Hello pruebauno, > import re > f=file('tlst') > tlst=f.read().split('\n') > f.close() tlst = open("tlst").readlines() > f=file('plst') > sep=re.compile('Identifier "(.*?)"') > plst=[] > for elem in f.read().split('Identifier'): > content='Identifier'+elem > match=sep.search(content) > if match: > plst.append((match.group(1),content)) > f.close() Look at re.findall, I think it'll be easier. > flst=[] > for table in tlst: > for prog,content in plst: > if content.find(table)>0: if table in content: > flst.append('"%s","%s"'%(prog,table)) > flst.sort() > for elem in flst: > print elem print "\n".join(sorted(flst)) HTH. -- Miki Tebeka <[EMAIL PROTECTED]> http://tebeka.bizhat.com The only difference between children and adults is the price of the toys pgp9Fde43cw8j.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
Re: HTML tags optimization [better learn CSS]
I know very well Tidy, sir Tidy do a nice job but it is writen in Java, and have Python ported my aim is to learn Python, learn how to program I know many people write "hello the world" in 2005, why I can not write this program in 2005? you are french, right? peut etre we can talk about it in ecole polytechnique? i'll be there waiting for you thanks -- http://mail.python.org/mailman/listinfo/python-list
Is my thread safe from premature garbage collection?
Hello all, I'm aware that in Python an object is cleared for garbage collection as soon as the last reference to it disappears. Normally this is fine. However, in my current project I'm creating a bunch of threads which are supposed to run until they've completed their run() method, and I'm worried that if I do not keep references to these thread objects around, the GC might happily delete them (and thereby kill my thread routines maybe?) while they're not done yet. Is this fear justified? Or is the Python GC smart enough to leave thread objects alone until their run() methods have finished? If not, I do have a workaround, but it is a bit clumsy IMO. Basically I would just keep a list into which each thread object enters a reference to itself on creation. This way I'd ensure that I have a reference to the thread to prevent the GC from killing it. Then, when a thread is about to finish its run() method, the thread finds and removes that reference to itself from my list of thread references. Anyway, if anyone could make a definite statement on whether threads are safe from unwanted garbage collection, that'd be really great. Thanks in advance for any helpful replies! Cheers, antred -- http://mail.python.org/mailman/listinfo/python-list
Re: Well, Python is hard to learn...
Well, I reckon it all depends on how much experience you have with programming languages in general. If you're completely new to programming it's probably going to take a while to get to grips with it all, regardless of which language you're picking up, although I'd wager that Python is still one of the most intuitive and easiest to learn languages around. Personally I learnt to code in C++ Python, and Perl with a little bit of Java, Tcl and C# thrown in there as well and I like Python and C++ the most. Just be patient, mate, you'll get the hang of it before long. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Asynchronous I/O library (pyasynchio) [currently win-only]
Vladimir Sukhoy wrote: > This Python library is created to support asynchronous I/O > (Input/Output) operations. Unlike most platform-independent asynch I/O > libraries, pyasynchio is simple. You do not have to know much about > programming and anything about AIO in particular to use pyasynchio. > Unlike, for example, famous asyncore library, pyasynchio does not > require you to use some object-oriented approaches, implement certain > interfaces or do anything similar. nice. (but I'm not sure writing large if-else trees and state machines is that much easier than implementing hook methods, whether you know much about programming or not. have you considered the case where you want your program to handle *different* protocols? how do you associate state with sockets in your programming model?) (and why return dictionaries? wouldn't an ordinary object be a better choice in this case? evt['type'] isn't really that pythonic compared to evt.type. an attribute-based approach also lets you delay construction of Python objects until the client code actually attempts to use it). (and given that the users will have to check the type and success fields for every single event, wouldn't it be better to return those as separate values: "for op, ok, event in apoll.poll(): if op == '...': ...") -- http://mail.python.org/mailman/listinfo/python-list
Re: using python_ldap for authentication
> but it seems to succeed whatever the password I'm providing :-( > > How to simply assess the binding really occured ? It should work... If you are anxious have a look to your ldapserver logs, you can see the bind . Try with an account that have modify rights et do a modify request if it fails you know there is a problem... > Do I need to start doing stuff with the "l" object to catch an error > and realize I'm not in fact connected : that's my current workaround > but I'm not very proud of it... Try: Your code initialize bind except ldap.LDAPError,e: . see http://homepage.mac.com/mengelhart/python-ldap-samples.html jmp -- http://mail.python.org/mailman/listinfo/python-list
Re: OpenSource documentation problems
By the way, i have sent my criticisms to the proper python doc maintainer or mailing list several months ago. - i'm very sorry to say, that the Python doc is one of the worst possible in the industry. I'm very sick of Perl and its intentional obfuscation and juvenile drivel style of its docs. I always wanted to learn Python as a replacement of Perl, and this year i did. I thought Python is much better. But now i know, that although the language is better, but its documentation is effectively worse than Perl's. The Perl docs, although lousy in the outset because its people immerse in drivel. It is part of their unix culture. Nevertheless, one thing Perl doc is not, is that it in particular do not presume a superficial Computer Science stance. In fact, its culture sneer computer science establishment. (which i caused major harm in the industry) There are quite a lot things wrong with Perl docs. But at least it is not shy to use examples, lots of them. Now, i have thought that Python doc is entirely different. The Python community in many ways are antithesis of Perl community. Python doesn't start with a hacking mentality, and i presume it to have a community who care about correctness and quality. Unfortunately, as i now know, its doc is the worst and almost useless piece of shit. Several problems lies at the core: * its technical writing is extremely poor. * its technical content clearly shows that the writers can't or didn't think clearly. (one confused ball) * its organization exhibits the worst abstruse insensibilities of tech geekers. as i have expressed before (see http://xahlee.org/Periodic_dosage_dir/t2/xlali_skami_cukta.html ), the python doc has huge number of problems. To remedy them, it needs major overhaul if not complete rewrite. Just about the only worthwhile part of the official doc set is the Tutorial section. The “Language Reference” section, Library Reference, and The Global Module Index are totally crap and need to be deleted entirely. (i haven't read much of the other sections, but i don't assume they are much better) - I would like to see the Python doc gets a complete rewrite. First of all, the doc system LaTex needs to go. (TeX itself is a OpenSource crime, see this unedited rant http://xahlee.org/Periodic_dosage_dir/t2/TeX_pestilence.html ) Then, the doc needs to be written with a few principles. * to communicate to programers how to use it. (as opposed to being a compiling specification or inline with some computer sciency model) * write with the goal of effective communication. In the writing, avoid big Engish words, long sentences, and focus on precision. In content, avoid philosophical outlook, jargon population, author masturbation, arcane technicalities, gratuitous cautions, geek tips, juvenile coolness ... etc.) * document with consideration of tasks to be performed. * document orient with the language's exhibited functionalities, concrete behaviors. (as opposed to in some milieu of software engineering methodology) * give ample examples. (for detail, study several of my Python criticisms from the link mentioned above) -- I have not been in the Python community long and have not delved into it. Is there other documentation that can be a basis of a new python doc? The one i know is the Quick Reference by Richard Gruet. However, it is just a Quick Reference but can be a basis if we lack anything else. Also, i have happened to read the O'Reilly Python book years ago. That book is crap. I have also read parts of the Python Cookbook. Probably half of this book is also crap. Of course, the other major hurdle in progress (for a new doc) is a political one. It is, alas, always the biggest problem. --- the python doc wiki given at http://pydoc.amk.ca/frame.html is a great idea. For this to work, there are two things needs to be done, both are equally important: 1. for the official python site Python.org to point to the wiki as THE official python doc. 2. given a authoritarian guide in the wiki on how to write the doc. (the guide based on the principles i gave above. Of course, it needs to be clarified and elaborated with many cases in point.) Without (1), the wiki will never be prominent. Without (2), it will remain a geek drivel. (in this respect, similar to how wikipedia's texts drift into a form of academic esoterica whose educational value are greatly reduced to the general public.) this post is archived at http://xahlee.org/UnixResource_dir/writ/python_doc.html Xah [EMAIL PROTECTED] ∑ http://xahlee.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Well, Python is hard to learn...
wen wrote: > due to the work reason, i have to learn python since last month. i have > spent 1 week on learning python tutorial and felt good. but i still don't > understand most part of sourcecode of PYMOL(http://pymol.sourceforge.net/) > as before. > > it sucks. No, please, don't say that. It is _not_ Python's fault. PyMol is a _large_ and _complex_ piece of software. I would be happy to understand a _very small_ part of its source code after having studied Python for just a week or so. Python is one of the easiest programming language around but it cannot make simple a complex task like molecular design or molecular dynamic (I'm a chemist and I can understand your disappointment). You will have to wait _months_ before being able to understand such a complex piece of software well enough to be able to play with its source code. But... do you really need to play with the source code of this program? Do you really have to tweak its code to fit your needs? Could not be enough to write some plug-in, some wrapper or some other kind of "external" program? This would be much easier. HTH --- Alessandro Bottoni -- http://mail.python.org/mailman/listinfo/python-list
Re: HTML tags optimization [ interesting problem]
I know very well Tidy, sir Tidy do a nice job but it is writen in Java, and have Python ported my aim is to learn Python, learn how to program I know many people write "hello the world" in 2005, why I can not write this program in 2005? you are french, right? peut etre we can talk about it in ecole polytechnique? i'll be there waiting for you thanks -- http://mail.python.org/mailman/listinfo/python-list
Win32: Possible to use Python to create Snap-Ins for MMC?
Is it possible to use Python to create snapins for the MMC? Thanks, Harlin Seritt Internet Villa: www.seritt.org -- http://mail.python.org/mailman/listinfo/python-list
Re: SpamBayes wins PCW Editors Choice Award for anti-spam software.
[Alan Kennedy] >> ... PCW ran a story this time last year >> about Michael Sparks, python and python's use in the BBC's future >> distribution plans for digital TV. [Paul Boddie] > Well, I didn't even notice the story! ;-) Here's the message I posted here at the time http://groups.google.com/group/comp.lang.python/msg/4a33f07f11a0ef30 regards, -- alan kennedy -- email alan: http://xhaus.com/contact/alan -- http://mail.python.org/mailman/listinfo/python-list
Re: Is my thread safe from premature garbage collection?
[EMAIL PROTECTED] a écrit : > Anyway, if anyone could make a definite statement on whether threads > are safe from unwanted garbage collection, that'd be really great. > Thanks in advance for any helpful replies! As far as I know, the threading module keeps a reference around for each thread, until its target method returns. I frequently use a thread without keeping any reference to it and never encountered any problem. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is my thread safe from premature garbage collection?
[EMAIL PROTECTED] wrote: > Hello all, > > I'm aware that in Python an object is cleared for garbage collection as > soon as the last reference to it disappears. Normally this is fine. > However, in my current project I'm creating a bunch of threads which > are supposed to run until they've completed their run() method, and I'm > worried that if I do not keep references to these thread objects > around, the GC might happily delete them (and thereby kill my thread > routines maybe?) while they're not done yet. Is this fear justified? Or > is the Python GC smart enough to leave thread objects alone until their > run() methods have finished? > > If not, I do have a workaround, but it is a bit clumsy IMO. Basically I > would just keep a list into which each thread object enters a reference > to itself on creation. This way I'd ensure that I have a reference to > the thread to prevent the GC from killing it. Then, when a thread is > about to finish its run() method, the thread finds and removes that > reference to itself from my list of thread references. > > Anyway, if anyone could make a definite statement on whether threads > are safe from unwanted garbage collection, that'd be really great. > Thanks in advance for any helpful replies! The threading module does already take care of keeping references to all running threads, so there's no need to do it yourself and your threads are safe from being garbage collected. -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Is my thread safe from premature garbage collection?
Splendid! =) Thanks guys! -- http://mail.python.org/mailman/listinfo/python-list
pexpect.exitstatus not working?
This function: def scp(from_path,to_path,pwd): """Copy a file with scp.""" cmd = '/bin/csh -c "scp -q %s %s ; echo XXX"' %(from_path,to_path) print cmd child = pexpect.spawn(cmd) child.expect('Password:') child.sendline(pwd) child.expect('XXX') return child.exitstatus always returns None. This one: def scp(from_path,to_path,pwd): """Copy a file with scp.""" cmd = 'scp -q %s %s ' %(from_path,to_path) print cmd child = pexpect.spawn(cmd) child.expect('Password:') child.sendline(pwd) child.interact() return child.exitstatus will return the correct exit status. The big problem is that I would like to run this function from a cron job. Inside a cron job, interact() will not work because it is not connected to a real terminal. How can I get the exit status code? Please help me. Les -- http://mail.python.org/mailman/listinfo/python-list
Re: To the python-list moderator
Terry Hancock wrote: > I got one of these too, recently. Maybe somebody is turning up the > screws to get rid of spam that's been appearing on the list? I've been getting these about once a day lately. at first, I suspected some kind of "you're posting to quickly"-filter with a manual "okay, you're whitelisted for another 24 hours" setup, but it seems to block messages mostly by random. and some messages don't seem to get through at all. slightly annoying. -- http://mail.python.org/mailman/listinfo/python-list
Decrypting GPG/PGP email messages
I know you will shake you head sadly but... I really have to perform such a suicidal task (even if for a short time and just for internal use). I have to send by email (over the open internet) a XML file containing _system commands_ (yes: the kind of stuff like "rm -dfr /") to a server and have a Python program sitting on this server, fetching and parsing the e-mail message and executing the commands (maybe with _root privileges_). Of course, I want to be sure that only the allowed people is able to send such dangerous messages to my server so I will ask my users to encrypt and digitally sign their messages using Thunderbird, Enigmail and GPG as described in this very fine tutorial: http://goldenspud.com/webrog/archives/2005/03/10/encrypt-encrypt/ So far, so good, but I still have a couple of doubts about the server side: 1) What would you use to decrypt the messages? The GPG module created by Andrew Kuchling is declared "incomplete" and "no more maintained" on his web pages (http://www.amk.ca/python/code/gpg) so I think it is out of the game. Would you use OpenPGP (http://www.aonalu.net/openpgp/python)? Any other module? 2) I did not find any mention of _encrypted attachments_ on the Net. Does anybody know of a tutorial or a guide that explains how to encrypt (with Thunderbird/Enigmail) and decrypt (with Python) the (ANSI text) files attached to a email message? TIA --- Alessandro Bottoni -- http://mail.python.org/mailman/listinfo/python-list
Re: Extended Language c++ in pyhton
Decide your self: http://seal.web.cern.ch/seal/snapshot/work-packages/scripting/evaluation-report.html My recomendation is boost.python. If you choose boost.python then there are a few code generator tools for it. One of them is pyplusplus ( see http://pygccxml.sourceforge.net/pyplusplus/pyplusplus.html ) Roman On 9/1/05, elho <[EMAIL PROTECTED]> wrote: > I found serveral tool for using C++ as extended languate in python - but > what's the best / easiest to use? > > With C I used wrappy - not sure if it's the wright name, it's included > since Python 1.6 and it ist pretty ease to use. You know an example with > this util for C++ or isn't it possible for C++. > > Would be nice to get your opinion. thx > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: SpamBayes wins PCW Editors Choice Award for anti-spam software.
[Alan Kennedy] >>IMHO, there is a great opportunity here for the python community: > > [...] > >>Surely that's worth a simple team name, for mnemonic purposes >>if nothing else. Something different or unusual, like one of my >>favourites, "Legion of the Bouncy Castle", who are a group of Java >>cryptography dudes [Tony Meyer] > Is there really anything to be gained by referring to the "SpamBayes > development team" via some cryptic name? Yes, there is something to be gained: mindshare. A simple catchy memorable team name could work wonders for showing potential users that this excellent open-source software product was produced a team of real people, using the worlds best development language ;-) And produced by people who have a pythonic sense of humour. Off the top of my head suggestions include - The Python Anti-Spam Cabal - The Flying Circus - The SPAM Vikings (*) - The Knights who go Nih - The Ministry of Funny Software - Masters of the pythonic time machine (probably too pretentious) * http://www.2famouslyrics.com/m/monty-python/spam-song.html [Tony Meyer] > You can call use the SDT if you like. Well, I said an interesting name ;-) [Tony Meyer] > Should the Python developers likewise get some cryptic name? No, they'll always be the python-dev cabal to me. basic-marketing-is-easy-ly'yrs, -- alan kennedy -- email alan: http://xhaus.com/contact/alan -- http://mail.python.org/mailman/listinfo/python-list
Re: Decrypting GPG/PGP email messages
Alessandro Bottoni <[EMAIL PROTECTED]> writes: > 1) What would you use to decrypt the messages? The GPG module created by > Andrew Kuchling is declared "incomplete" and "no more maintained" on his > web pages (http://www.amk.ca/python/code/gpg) so I think it is out of the > game. I think I'd just run gpg as an external command. I've done that from perl scripts and it's pretty simple. > Would you use OpenPGP (http://www.aonalu.net/openpgp/python)? Any > other module? Oh hey, I didn't know about that, I'll have to look at it. I started writing something similar a long time ago and got as far as being able to decrypt straightforward messages, and have been meaning to get back to it. But it's great if someone else is doing it more seriously.q > 2) I did not find any mention of _encrypted attachments_ on the Net. Does > anybody know of a tutorial or a guide that explains how to encrypt (with > Thunderbird/Enigmail) and decrypt (with Python) the (ANSI text) files > attached to a email message? PGP/GPG have their own base64 encoding called "ascii armor" in PGP lingo. This stuff predates widespread use of MIME and traditionally, PGP messages are sent as ascii armored plain text, not attachments. You'd just send messages like: From: alice To: bob Subject: encrypted message -BEGIN PGP MESSAGE- Version: GnuPG v1.2.1 (GNU/Linux) jA0EAwMC+QyBtnf2kVxgyUgkWXDwnHHu6GR8xYJ4GuorEo8t9BHfExmcwCyUok/z wZsmoCCdulYjLnAjgU0WZRhe7woCrgy14pzc7PSOhqRPEG1IFJqeZuM= =5l/P -END PGP MESSAGE- Note the complete absence of mime headers and separators. As far as the mail agents are concerned, the message is just text. I'm not sure how the Thunderbird/Enigmail plugins work. -- http://mail.python.org/mailman/listinfo/python-list
Open-Office ; Python & Win (plain/text)
Open-Office 2.0 bêta-2 français pour Windows (en fait, la 1.9.125 ) est sortie. Vous la trouverez là : http://oootranslation.services.openoffice.org/pub/OpenOffice.org/2.0beta2rc/OOo_2.0beta2_Win32Intel_install_fr.zip Je cite ce lien, car j'ai réussi à piloter Open-Office, depuis Python, avec PyWin32. Vous trouverez ci dessous le script expérimental (code "brut" et méchant ; mais c'est la faisabilité qui importe ici). Ce script fonctionne avec le fichier Open-office C:\\ootest.odt qui contient : - BBB CCC 111%TXT1%111 22 %CADRE1% 333 Aaz aze ABC djhevgd fude uftyf ofh efzehiufre hiufre zefoz hfzr hruifh ABC ABC gyuguyg ufg eruzyfgerABCABC efeorzehfzrehiufreh ABC - Recréez ce fichier, puis lancez le script ci-dessous. Ensuite, ben... lisez le code-source, et débrouillez-vous... --- Michel Claveau PS : je poste ce message en HTML, puis en plain/text, pour faciliter les choses. - # -*- coding: cp1252 -*- import win32com.client import time def insertIntoCell( strCellName, strText, objTable): objCellText = objTable.getCellByName( strCellName) objCellCursor = objCellText.createTextCursor() objCellCursor.setPropertyValue("CharColor",16777215) objCellText.insertString(objCellCursor, strText, False) objServiceManager = win32com.client.Dispatch("com.sun.star.ServiceManager") objDesktop = objServiceManager.CreateInstance("com.sun.star.frame.Desktop") args = [] #si nouveau document, ligne suivante #objDocument = objDesktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, args) """ //swriter pour le traitement de texte. //scalc pour le tableur //sdraw pour l'éditeur de dessin //simpress pour l'éditeur de présentation (équivalent de PowerPoint) //smath pour l'éditeur de formule mathématique //swriter/Global Document document maitre //swriter/web Pour l'éditeur HTML """ #si document existant objDocument = objDesktop.loadComponentFromURL("file:///C:/ootest.odt", "_blank", 0, args) objText = objDocument.GetText() objCursor = objText.createTextCursor() objText.insertString(objCursor, "Vous avez les salutations de PONX.\nCeci est la deuxième ligne.\n", 0) objText.insertString(objCursor, "Troisième ligne.\n", 0) objText.insertString(objCursor, "4è ligne [EMAIL PROTECTED]", 0) # Tableau #Crée un tableau de 4 colonnes x 4 lignes objTable= objDocument.createInstance( "com.sun.star.text.TextTable") objTable.IsWidthRelative = True objTable.RelativeWidth = 80 # largeur de 80 % objTable.BackColor = 255*256*256+255*256+204 # fond en jaune clair objTable.HoriOrient = 2 # 0 LEFT 1 RIGHT 2 CENTER objTable.initialize(8, 4) # lignes / colonnes #Insère la table objText.insertTextContent(objCursor, objTable, 0) #1ère ligne objRows = objTable.getRows() objRow0 = objRows.getByIndex(0) #Couleur de fond objTable.setPropertyValue("BackTransparent", 0) objTable.setPropertyValue("BackColor", 255*256*256+255*256+204) #Autre couleur de fond, pour la première ligne objRow0.setPropertyValue("BackTransparent", 0) objRow0.setPropertyValue("BackColor", 6710932) objRow0.setPropertyValue("IsAutoHeight", False) objRow0.setPropertyValue("Height", 3000) #30 mm #Remplissage 1ère ligne insertIntoCell("A1","FirstColumn",objTable) insertIntoCell("B1","SecondColumn",objTable) insertIntoCell("C1","ThirdColumn",objTable) insertIntoCell("D1","SUM",objTable) #Remplissage suite objTable.getCellByName("A2").setValue(22.5) objTable.getCellByName("B2").setValue(5615.3) objTable.getCellByName("C2").setValue(-2315.7) objTable.getCellByName("D2").setFormula("sum(||)") objTable.getCellByName("A3").setValue(21.5) objTable.getCellByName("B3").setValue(615.3) objTable.getCellByName("C3").setValue(-315.7) objTable.getCellByName("D3").setFormula("sum()") objTable.getCellByName("A4").setValue(121.5) objTable.getCellByName("B4").setValue(-615.3) objTable.getCellByName("C4").setValue(415.7) objTable.getCellByName("D4").setFormula("sum ") #on sélectionne la colonne C sCell = objTable.createCursorByCellName("C1") sCell.goDown(4, True) sCell.BackColor = 255*256*256+200*256+200 #rouge clair """ ça ne marche pas (spécif OO-2.0 ?) cols = objTable.getColumns() col = cols.getByIndex(2) """ #Couleur des caractères et ombre objCursor.setPropertyValue("CharColor", 255) objCursor.setPropertyValue("CharShadowed", True) #Saut de paragraphe #The second argument is a com::sun::star::text::ControlCharacter::PARAGRAPH_BREAK constant objText.insertControlCharacter(objCursor, 0 , False) #Insertion texte objText.insertString(objCursor, " Texte coloré - bleu avec ombre\n", False) #Saut de paragraphe (caractère spécial PARAGRAPH_BREAK = 0). objText.insertControlCharacter(objCursor, 0, False) #
Re: Code run from IDLE but not via double-clicking on its *.py
[n00m] > D:\>python23\python d:\python23\socket6.py [Enter] > > It's OK so far. Python code is launched and starts listening > to port 1434 (see the code below; it's the same code as in my > neibouring topic). > Now I launch a vbs script (which will connect to port 1434). > I.e. I just double-click "my.vbs" file. > And... voila! In a moment & silently console window closes > without any error messages (or I just don't see them). > But VBS reports a network error. Tested on win2k and win98. That sounds impossible, so I must be misunderstanding something. What happens when you do this (forgive me if this seems patronising, but I'm missing something about the way you're working) 1. Start a new Command Prompt via Start / Programs / Accessories / Command Prompt (or the equivalent on your machine) 2. Type the following: d:\python23\python d:\python23\socket6.py [Enter] 3. Double-click your .vbs file in Windows Explorer. Now what does the python Command Prompt say? By your description above, it sounds like it disappears, but that ought to be impossible. -- Richie Hindle [EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list
Re: Decrypting GPG/PGP email messages
Alessandro Bottoni wrote: > I know you will shake you head sadly but... I really have to perform such > a suicidal task (even if for a short time and just for internal use). > > I have to send by email (over the open internet) a XML file containing > _system commands_ (yes: the kind of stuff like "rm -dfr /") to a server > and have a Python program sitting on this server, fetching and parsing the > e-mail message and executing the commands (maybe with _root privileges_). > > Of course, I want to be sure that only the allowed people is able to send > such dangerous messages to my server so I will ask my users to encrypt and > digitally sign their messages using Thunderbird, Enigmail and GPG as > described in this very fine tutorial: > > http://goldenspud.com/webrog/archives/2005/03/10/encrypt-encrypt/ > > So far, so good, but I still have a couple of doubts about the server > side: > > 1) What would you use to decrypt the messages? The GPG module created by > Andrew Kuchling is declared "incomplete" and "no more maintained" on his > web pages (http://www.amk.ca/python/code/gpg) so I think it is out of the > game. Would you use OpenPGP (http://www.aonalu.net/openpgp/python)? Any > other module? What about using the command line program via os.pipeX("gpg...")? I've done it this way when I needed to _create_ encrypted mail attachments using python (you'll need different gpg options for decrypting): pipe_in, pipe_out = os.popen2("/usr/bin/gpg -q -r KEYID -s" "--passphrase-fd 0 --batch --no-tty -a -o - -e '%s'" % path_to_temporary_file) pipe_in.write("passphrase") pipe_in.close() # read encrypted file from pipe_out pipe_out.close() > 2) I did not find any mention of _encrypted attachments_ on the Net. Does > anybody know of a tutorial or a guide that explains how to encrypt (with > Thunderbird/Enigmail) and decrypt (with Python) the (ANSI text) files > attached to a email message? I can't help you with Thunderbird. In the worst case, you'll have to encrypt your command file manually and attach the encrypted version to your mail. KMail does have checkboxes for encrypt/sign every attachment separately... -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list
Re: OpenSource documentation problems
On Python's Documentation Xah Lee, 20050831 I'm very sorry to say, that the Python doc is one of the worst possible in the industry. I'm very sick of Perl and its intentional obfuscation and juvenile drivel style of its docs. I always wanted to learn Python as a replacement of Perl, and this year i did. I thought Python is much better. But now i know, that although the language is better, but its documentation is effectively worse than Perl's. • Official Perl doc: http://www.perl.com/pub/v/documentation • Official Python doc: http://python.org/doc/2.4.1/ The Perl docs, although lousy in the outset because its people immerse in drivel. It is part of their unix culture. Nevertheless, one thing Perl doc is not, is that it in particular do not presume a superficial Computer Science stance. In fact, its culture sneer computer science establishment. (which caused major harm in the industry) There are quite a lot things wrong with Perl docs. But at least it is not shy to use examples, lots of them. Now, i have thought that Python doc is entirely different. The Python community in many ways are antithesis of Perl community. Python doesn't start with a hacking mentality, and i presume its people care a lot more about correctness and quality. Unfortunately, as i now know, its doc is even worse than Perl's. Several problems lie at the core: its technical writing is extremely poor. (likewise Perl) its technical content clearly shows that the writers can't or didn't think clearly. (one confused ball; likewise Perl) its organization exhibits the worst abstruse insensibilities of tech geekers. (likewise Perl, exemplified by the infamous unix man pages, but at least Perl/unix has spunk) its organization and content presentation has a computer science pretension. The Computer Science Pretension aspect is the most egregious that does the most damage to the Python doc. The text became incomprehensible abstraction sans any example, and impossible to locate desired functionalities. Much like unix man pages, it requires the reader to have familiarity with the entire doc to be able to use it fruitfully. As i have expressed before (see http://xahlee.org/Periodic_dosage_dir/t2/xlali_skami_cukta.html ), the python doc has huge number of problems. To remedy them, it needs major overhaul if not complete rewrite. Just about the only worthwhile part of the official doc set is the Tutorial section. The “Language Reference” section (subtitled “for language lawyers”) needs to be replaced by human-readible descriptions of Python's functions. For exapmle, in the style of official Java doc (http://java.sun.com/j2se/1.4.2/docs/api/index.html). The Library Reference section and The Global Module Index are all in a very not useful state. These 3 section are all a incomprehensible blurr. i haven't read much of the other sections: • Macintosh Library Modules (for language lawyers) • Extending and Embedding (tutorial for C/C++ programmers) • Python/C API (reference for C/C++ programmers) • Documenting Python (information for documentation authors) • Installing Python Modules (information for installers & sys-admins) • Distributing Python Modules but all these should probably not be bundled with the official doc set. I would like to see the Python doc gets a complete rewrite. First of all, the doc system LaTeX needs to go. (TeX itself is a OpenSource crime, and its use as Python's doc system is a illustration of damage. See this unedited rant http://xahlee.org/Periodic_dosage_dir/t2/TeX_pestilence.html ) Then, the doc needs to be written with a few principles. to communicate to programers how to use it. (as opposed to being a semi description of implementation and compiler process, or inline with some computer sciency model or software engineering metholodogy fad) write with the goal of effective communication. In writing, avoid highbrow words, long sentences, and do focus on concision and precision. In content, avoid philosophical outlook, jargon population, author masturbation, arcane technicalities, gratuitous cautions, geek tips, juvenile coolness ... etc.) document with consideration of programer's tasks to be performed. document orient with the language's exhibited functionalities, concrete behaviors. (as opposed to in some milieu of computer sciency model.) give ample examples. (for detail, study several of my Python criticisms from the link mentioned above) I have not been in the Python community long and have not delved into it. Is there other documentation that can be a basis of a new Python doc? The one i know is the Quick Reference by Richard Gruet. ( http://rgruet.free.fr/PQR24/PQR2.4.html ) As a quick reference, it provides a concrete documentation of Python functionalities, and is a excellent basis for new documentation. However, being a Quick Reference it is very terse, consequently needs a lot work if it is to be a full documentation. Of course, the other major hurdle in prog
Re: pexpect.exitstatus not working?
Laszlo Zsolt Nagy wrote: >This function: > >def scp(from_path,to_path,pwd): >"""Copy a file with scp.""" >cmd = '/bin/csh -c "scp -q %s %s ; echo XXX"' %(from_path,to_path) >print cmd >child = pexpect.spawn(cmd) >child.expect('Password:') >child.sendline(pwd) >child.expect('XXX') >return child.exitstatus > >always returns None. > >How can I >get the exit status code? Please help me. > > I could develop a workaround, but this is a real hack, using bourne shell and the $? variable. def scp(from_path,to_path,pwd): """Copy a file with scp. Return the exit code.""" cmd = '/bin/sh -c "scp -q %s %s ; echo $? ; echo XXX "' %(from_path,to_path) print cmd child = pexpect.spawn(cmd) child.expect('Password:') child.sendline(pwd) child.expect("XXX") parts = [] for item in child.before.split('\n'): if item.strip() != "": parts.append(item.strip()) code = int(parts[-1]) print "exit code:", code if (code != 0): print parts[0] return code Is there a platform independent solution? Les -- http://mail.python.org/mailman/listinfo/python-list
Re: Python doc problems example: gzip module
nothing personal my friend. But just in case you are interested about getting it: the question here is about quality of documentation, not about whether you got it. http://xahlee.org/UnixResource_dir/writ/python_doc.html Xah [EMAIL PROTECTED] ∑ http://xahlee.org/ Sybren Stuvel wrote: > Xah Lee enlightened us with: > > but after a minute of scanning, please someone tell me what the fuck > > is it talking about? > > How difficult is it? The first line of the Gzip class explains it all > to me: "Constructor for the GzipFile class, which simulates most of > the methods of a file object" -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug in string.find; was: Re: Proposed PEP: New style indexing,was Re: Bug in slice type
> [snipped alot from others about indexing, slicing problems, > and the inadequacy of -1 as Not Found indicator] on 31.08.2005 16:16 Ron Adam said the following: > The problem with negative index's are that positive index's are zero > based, but negative index's are 1 based. Which leads to a non > symmetrical situations. Hear, hear. This is, for me, the root of the problem. But changing the whole of Python to the (more natural and consistent) one-based indexing style, for indexing from left and right, is... difficult. -- http://mail.python.org/mailman/listinfo/python-list
py2exe and output executable name
Hello All, Is there a way to tell py2exe to create an executable with arbirary name? Currently the executable name is the script name with .exe suffix. Thanks. -- Miki Tebeka <[EMAIL PROTECTED]> http://tebeka.bizhat.com The only difference between children and adults is the price of the toys pgpb9YpO7cGwo.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
Re: py2exe and output executable name
Miki Tebeka <[EMAIL PROTECTED]> writes: > Hello All, > > Is there a way to tell py2exe to create an executable with arbirary name? > Currently the executable name is the script name with .exe suffix. See the advanced sample in lib/site-packages/py2exe/samples/advanced. The executable name is defined by the 'dest_base' attribute of the Target class. This sample uses it to build a console *and* a gui version at the same time from the small wxPython script, with different names. Thomas -- http://mail.python.org/mailman/listinfo/python-list
Re: SpamBayes wins PCW Editors Choice Award for anti-spam software.
[Alan] > SpamBayes has won the Personal Computer World (pcw.co.uk) Editors Choice > award for anti-spam software Yay! Do we get one of those cheesy medals to put on our website? 8-) -- Richie Hindle [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: py to exe: suggestions?
Ivan Shevanski wrote: > Not sure if you already got the answer to this lol but since this is one > thing about python i do know how to do, use CXFreeze. Its basicly a > combination of all the programs you have already tryed. Works great for me > =D sorry I dont have a link, just google it. it's spelled cx_freeze, and can be found here: http://starship.python.net/crew/atuining/cx_Freeze/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Python built email message doesn't support OutLook Express
--- "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > That is not what Sybren requested - we need the > message text. If you > send html, make sure your paragraphs are html > paragraphs (enclosed in > -tags) and not pure whitespace, as html ignores > these. > I am sending text message as a paragraph __ How much free photo storage do you get? Store your friends 'n family snaps for FREE with Yahoo! Photos http://in.photos.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
Re: how to join two Dictionary together?
Read the list of dict methods at http://docs.python.org/lib/typesmapping.html Every Pythoneer should read LibRef c.2 at least once and either refer back to it or use help() to refresh memory of available methods. Terry J. Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Sockets: code works locally but fails over LAN
"n00m" <[EMAIL PROTECTED]> wrote: > PEOPLE, WHY ON THE EARTH IT DOES NOT WORK OVER LAN ??? what happens if you change s1.bind((host, port)) to s1.bind(("", port)) ? -- http://mail.python.org/mailman/listinfo/python-list
Re: Bicycle Repair Man usability
How would you setup BRM in VIM? And bonus points for explaining it for Windows users ;-) > I recently got PyDev for Eclipse, which comes with BRM.I use it from VIM. -- Gregory PiñeroChief Innovation OfficerBlended Technologies(www.blendedtechnologies.com) -- http://mail.python.org/mailman/listinfo/python-list
Re: Sockets: code works locally but fails over LAN
* n00m <[EMAIL PROTECTED]> [2005-08-31 05:45]: > import socket, thread > host, port = '192.168.0.3', 1434 > s1 = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > s2 = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > s2.connect((host, 1433)) > s1.bind((host, port)) I think the problem is that you're using the same host for both the send and recieve sockets. Wouldn't you want one host to be the localhost, and one to be sql server? If it doesn't work even when only the VBscript is on a different box, are you running an OS with a firewall that you have to disable? -John -- http://mail.python.org/mailman/listinfo/python-list
Re: OpenSource documentation problems
Steve Holden wrote: > I agree that maintaining documentation is a generic problem of the open > source world, but it's a sad fact of life that generally people are > better-motivated to complain about documentation (and almost everything > else) than to help improve it. another problem is that to be able to do really good work on the documentation, you need to know things well enough to "have the big picture". and once you have that, you'll find that the docs aren't really as bad as you once thought they were. -- http://mail.python.org/mailman/listinfo/python-list
Re: Extended Language c++ in pyhton
> Decide your self: > > http://seal.web.cern.ch/seal/snapshot/work-packages/scripting/evaluation-report.html A shame that it's so out of date. Phil -- http://mail.python.org/mailman/listinfo/python-list
Re: global interpreter lock
Dennis Lee Bieber wrote: > On Thu, 01 Sep 2005 06:15:38 GMT, Bryan Olson <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: >>With Python threads/queues how do I wait for two queues (or > > Why have two queues? Use one queue and tag the items with the > sender's "id" (or return queue). I've faced the same issue, and it stems from having existing classes which do not already support this sort of mechanism. Sure, you can sometimes design/redesign stuff to do exactly that, but much of the time you don't want to go rewriting some existing, stable code that waits on one queue just because you now need to throw another into the mix. -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: OpenSource documentation problems
Xah Lee wrote: > The "Language Reference" section (subtitled "for language > lawyers") needs to be replaced by human-readible descriptions of > Python's functions. For exapmle, in the style of official Java doc > (http://java.sun.com/j2se/1.4.2/docs/api/index.html). Nope. The Java documentation you're referring to corresponds to the "Library Reference" in Python, which is a collection of human-readable descriptions of Python's functions (whether you like them or not). Meanwhile, the corresponding Java documentation for Python's "Language Reference" is this document collection: http://java.sun.com/docs/books/jls/second_edition/html/jTOC.doc.html You'll notice that it resembles the Python documentation rather strongly. I'm afraid that the "Computer Science Pretension" is necessary with that kind of documentation so that "language lawyers" - ie. people implementing compilers, runtimes, tools - don't create something that doesn't work with genuine specimens of the language. Now, I don't doubt that Python's documentation could be improved, and I'm willing to improve it (and have improved it in the past). I even ticked the box on some feedback form at EuroPython to say that I'm willing to write Python docs. In fact, I may start looking at the documentation tasks on the Wiki and seeing what I can contribute, possibly from stuff I've already written but which doesn't trivially slot into the documentation as it is today. And I don't disagree with you that the PythonInfo Wiki is a structural mess (I can never manage to navigate from the front page to the WebProgramming page, although I obviously know the name of the page and don't need to, but this isn't going to help someone who doesn't know that it's there), nor do I disagree with you that TeX isn't exactly the most accessible technology. However, I would recommend that in order to be taken more seriously you tone down the rhetoric, review the available documentation (including stuff like "Dive Into Python" http://www.diveintopython.org/) and note the actual purpose of that documentation (eg. language vs. library reference) before suggesting the replacement of one text with another that already exists. > (in this respect, similar to how wikipedia's texts drift into a form of > academic > esoterica whose educational value and readibility are greatly reduced > to the general public.) And here's an example of that rhetoric I referred to. Personally, I find Wikipedia very readable even for my increasingly shortening attention span, and some academics would presumably argue that Wikipedia has already crossed some kind of line of compromise between accessibility and thoroughness. If you want things like the 1707 Act of Union (http://en.wikipedia.org/wiki/Act_of_Union_1707) explained to you without "esoterica", perhaps that says more about you than it does about Wikipedia. Please note that I'm not labelling you as a troll. As far as I can tell, many of your ideas are fairly sound; it's just that it's hard work to see past the rhetoric and posturing, which is a shame because you quite possibly have a lot to contribute. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: command line arguments
Jon Hewer wrote: >>What's the purpose of this utility? Is it to do something with the URL? >>And the URL must always be specified? What about the name? Also >>mandatory, or optional? The relationship between the two? > > > its just a simple rss reader. i'm writing it almost purely just to > get me using language (i'm learning python) it lets you save rss > feeds, and to do this one would specify a name and url (ie you have to > specify both), but there are other things it can do (remove a rss > feed, view a feed) hence i thought it was best to using command line > options In that case, consider making the URL or the name, or both, an argument *after* the options. The operation you want to perform would be specified with an option, possibly including an argument of its own if that information wasn't normally needed. For example (and keep in mind I really have no idea what RSS is useful for, and my sole exposure to it is to subscribe to the BBC Latest Headlines in Firefox): rssutil --add -nBBC http://fxfeeds.mozilla.org/rss20.xml rssutil --remove -n BBC rssutil --view http://fxfeeds.mozilla.org/rss20.xml or perhaps: rssutil -ahttp://fxfeeds.mozilla.org/rss20.xml BBC rssutil --remove BBC rssutil -v BBC I can't judge which blend of possibilities is more reasonable; I'm just trying to point out some of the thought process behind choosing an appropriate scheme. Making *everything* an option here just feels wrong, from a user interface point of view. -Peter -- http://mail.python.org/mailman/listinfo/python-list
Extend Python
Hi All I have a problem with extentions of Python. Background: I'm workin within a large industrial control system and I have created a Port for VxWorks. In the system we have different permissions depending on which state the controller is in. To perform some actions in some states may even injure or kill people. Therefor we need "intelligent" wrappers between Python and C-code. My Question: Swig offers some great features but is to basic for us. Is there another program that creates more readble code that can be easily edited? How much work is it to write our own wrappers? //T -- http://mail.python.org/mailman/listinfo/python-list
Re: cgi, reusing html. common problem?
On Thu, 01 Sep 2005 03:10:07 -0400, "John M. Gabriele" <[EMAIL PROTECTED]> wrote: >I'm putting together a small site using Python and cgi. > >(I'm pretty new to this, but I've worked a little with >JSP/servlets/Java before.) > >Almost all pages on the site will share some common (and >static) html, however, they'll also have dynamic aspects. >I'm guessing that the common way to build sites like this >is to have every page (which contains active content) be >generated by a cgi script, but also have some text files >hanging around containing incomplete html fragments which >you read and paste-in as-needed (I'm thinking: >header.html.txt, footer.html.txt, and so on). > >Is that how it's usually done? If not, what *is* the >usual way of handling this? > Having a template and inserting dynamic values into it is very common. You'll have more luck looking for 'python templating systems'. I use a module called 'embedded code' - which is part of firedrop by Hans Nowak. See http://www.voidspace.org.uk/python/firedrop2/ Popular templating engines include Cheetah and TAL. You can also roll your own basic one using the string method ``replace``. I'm pretty sure their is an entry on the Python.org WIKI about templating. All the best, Fuzzy http://www.voidspace.org.uk/python >Thanks, >---John -- http://mail.python.org/mailman/listinfo/python-list
Re: Considering moving from PowerBuilder to Python
> Also, can I use Sybase's SQL Anywhere with Python? > > I'm really only interested in programming for Windows XP. But I also really > would like to find something very close to Sybase's patented datawindow > technology -- it's a real time-saver. > > Finally, is there any (realistic) way to mix PowerBuilder and Python? For > instance write a Python shell that calls PowerBuilder methods (or vice > versa). For Sybase-specific questions there's gmane.comp.python.sybase... >;-> Sincerely, Wolfgang Keller -- http://mail.python.org/mailman/listinfo/python-list
Re: 'isa' keyword
On 1 Sep 2005 00:52:54 -0700, "talin at acm dot org" <[EMAIL PROTECTED]> wrote: >Although I realize the perils of even suggesting polluting the Python >namespace with a new keyword, I often think that it would be useful to >consider defining an operator for testing whether or not an item is a >member of a category. > >Currently, we have the 'in' operator, which tests for membership within >a container, and that works very well -- in particular, it allows such >membership tests to be expressed in very natural way. So for example, >whereas in C++ I always have to say: > >if (dependencies.find( name ) != dependencies.end()) > >in Python I can simply say: > >if name in dependencies: > >...which is much more readable and intuitive. At the same time, >however, I recognize that there is a logical difference between >membership in a container, and membership in a category. For example, >although a bear is a member of the class of mammals, it doesn't make as >much to say "if bear in mammal". Similarly, you wouldn't want to use >the 'in' keyword as a replacement for isinstance(), i.e. "if name in >str". > >I propose the word 'isa' because the term 'isa hierarchy' is commonly >used to indicate a tree of types. So the syntax would look like this: > >if bear isa mammal: >if name isa str: > What's the difference between this and ``isinstance`` ? Best Regards, Fuzzy http://www.voidspace.org.uk/python -- http://mail.python.org/mailman/listinfo/python-list
The penis is way too delicate for masturbation
. -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug in string.find
Ron Adam wrote: > The problem with negative index's are that positive index's are zero > based, but negative index's are 1 based. Which leads to a non > symmetrical situations. indices point to the "gap" between items, not to the items themselves. positive indices start from the left end, negative indices from the righept end. straight indexing returns the item just to the right of the given gap (this is what gives you the perceived assymmetry), slices return all items between the given gaps. -- http://mail.python.org/mailman/listinfo/python-list
Re: Well, Reading is hard to learn...
wen wrote: > due to the work reason, i have to learn python since last month. i have > spent 1 week on learning python tutorial and felt good. but i still don't > understand most part of sourcecode of PYMOL(http://pymol.sourceforge.net/) > as before. > > it sucks. > I have spent 1 week on learning reading and felt good. but I still don't understand most part of Emmanuel Kant's writings. Wen, please don't take it bad !-) What I mean is that something inherently complex will be difficult to understand whatever the language. And I guess that something like PyMOL would be *much more* difficult to understand if it was implemented in C++. -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list
Re: Inline::Python, pyperl, etc.
Eli Stevens (WG.c) wrote: > PyPerl 1.0.1 > http://wiki.python.org/moin/PyPerl > > The interest in these projects seems to have died off about 2001, > however. That, or they simply haven't needed to be updated for the last > few Python versions. > > I've bumped into some snags with pyperl (can't import perl2.so? But > it's right there in site-packages/ !), and I'm wondering if it's bitrot > or a config error on my end. > > Similarly, with Inline::Python I end up getting strings passed into my > python code when I expect integers (I posted about this on > inline@perl.org, but things seem pretty dead over there). > > Is anyone actually using any of this stuff? I made some patches to pyperl and the unit testing suite some months ago. At least basic functionality is working again. Have a look at the zope-perl mailing list. I don't know if I announced a single source tar.gz on this mailing list but if you have still some interest in this I can mail you the package. fs -- http://mail.python.org/mailman/listinfo/python-list
Re: HTML tags optimization [better learn CSS]
DENG wrote: > I know very well Tidy, sir > > Tidy do a nice job but it is writen in Java, Seems like we're not talking about the same program here. Tidy (aka HTMLTidy) is written in C. You must be talking about it's Java port JTidy. > and have Python ported > > my aim is to learn Python, learn how to program No one could have guess from your post, and I dont have psychic powers, ok ? >From a professional POV, using existing tools that have proven to be reliable is far better than reinventing the square wheel, hence my answer. > you are french, right? peut etre we can talk about it in ecole > polytechnique? Peut-être pas, je ne mets jamais les pieds chez les polytechniciens. > i'll be there waiting for you I'm afraid you'll learn a long time. Regards, -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list
Creating custom event in WxPython
Hello, I'm faced with the following problem: I have a (secondary) thread that monitors a socket for incoming message traffic using the select.select() function. Besides that I also have the main thread of my WxPython application. So far so good. Now when my socket thread detects an incoming message, I need my main thread to interpret the message and react to it by updating the GUI. IMO the best way to achieve this is by having my socket thread send a custom event to my application's event loop for the main thread to process. However, I'm at a total loss as far as creating custom events is concerned. The WxWindows documentation isn't very helpful on this either. I think I need to derive my own event class from the wxEvent class, but I have no idea HOW (i.e. what methods do I need to override, etc.) Can anyone help me? -- http://mail.python.org/mailman/listinfo/python-list
Re: Code run from IDLE but not via double-clicking on its *.py
It's soo pity I'm too buzy at my work today. I'll reply a bit later. Thank you, guys! PS Port 1433 SQL Server listens to. PPS SQL Server is a rdbms from M$. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is my thread safe from premature garbage collection?
In article <[EMAIL PROTECTED]>, Benjamin Niemann <[EMAIL PROTECTED]> wrote: >[EMAIL PROTECTED] wrote: >> However, in my current project I'm creating a bunch of threads which >> are supposed to run until they've completed their run() method, and I'm >> worried that if I do not keep references to these thread objects >> around, the GC might happily delete them (and thereby kill my thread >> routines maybe?) while they're not done yet. Is this fear justified? >The threading module does already take care of keeping references to all >running threads, The implementation of threading.enumerate() would be entertaining if it didn't. Quite apart from which, I presume the OP's run() method looks something like: class MyThread(threading.Thread): def run(self): ... So what is self if not a reference to the Thread object which is kept around until run() has completed? -- \S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/ ___ | "Frankly I have no feelings towards penguins one way or the other" \X/ |-- Arthur C. Clarke her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump -- http://mail.python.org/mailman/listinfo/python-list
Re: Well, Reading is hard to learn...
bruno wrote: > > I have spent 1 week on learning reading and felt good. but I still don't > understand most part of Emmanuel Kant's writings. > Monty Python really missed out there: cut to a sketch featuring three year olds discussing Kant. ;-) Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Extend Python
PyQT is using SIP to wrap Qt : looks nice and works great for PyQt which is a quite big wrapping. Never had the occation to use it myself however, except for this. -- http://mail.python.org/mailman/listinfo/python-list
scroll a frame to display several lines of widgets at a time
I need to display a couple of labels and a checkbox from each entry in my database. Simple enough, but there are several hundred records, and I only want to display 5 or 10 at a time. Can this be accomplished by putting everything in a Frame(), using width, height, grid_propagate(0) , and a scrollbar? or do I have to grid 5 rows at a time? If the latter, can I just grid over the previous 5 or do they have to be explicitly removed first. Thanks. Bill -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating custom event in WxPython
<[EMAIL PROTECTED]> wrote: >Now when my socket thread detects an incoming message, I need my main >thread to interpret the message and react to it by updating the GUI. >IMO the best way to achieve this is by having my socket thread send a >custom event to my application's event loop for the main thread to >process. However, I'm at a total loss as far as creating custom events >is concerned. The WxWindows documentation isn't very helpful on this >either. >I think I need to derive my own event class from the wxEvent class, but >I have no idea HOW (i.e. what methods do I need to override, etc.) Can >anyone help me? (a) Consider whether you can do what you want with CallAfter(). (b) If you do have to go with a custom event, the idiom I've got here is: EVT_CUSTOM_WITH_DATA_ID = wxNewId() def EVT_CUSTOM_WITH_DATA(win, func): win.Connect(-1, -1, EVT_CUSTOM_WITH_DATA_ID, func) class CustomWithDataEvent(wxPyEvent): def __init__(self, data=None): wxPyEvent.__init__(self) self.data = data self.SetEventType(EVT_CUSTOM_WITH_DATA_ID) def Clone(self): return CustomWithDataEvent(self.data) but do note that this is for wxPython2.4 -- amongst other differences, EVT_CUSTOM_WITH_DATA() should be unnecessary in 2.6 (used Bind() instead). -- \S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/ ___ | "Frankly I have no feelings towards penguins one way or the other" \X/ |-- Arthur C. Clarke her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump -- http://mail.python.org/mailman/listinfo/python-list
Re: Considering moving from PowerBuilder to Python
Norm Goertzen wrote: > I've posted a previous question about IDEs and got some good feedback, > thanks, but it does seem that everyone has their own favourite IDE -- in > other words, no IDE was repeatedly recommended. > > So, is there any data on the popularity of IDEs (most users), or is > there a chart comparing the most popular versions. > > I'M NOT AFRAID TO SPEND SOME MONEY TO GET THE RIGHT IDE (but I don't > want to change products once I've chosen). > > Also, can I use Sybase's SQL Anywhere with Python? > > I'm really only interested in programming for Windows XP. But I also > really would like to find something very close to Sybase's patented > datawindow technology -- it's a real time-saver. > > Finally, is there any (realistic) way to mix PowerBuilder and Python? > For instance write a Python shell that calls PowerBuilder methods (or > vice versa). > > Thanks again, > Norm Hi Norm, I was kind of in your situation wherby I had to do a lot of python programming under XP. This was in a major porting project to linux. Although you have a choice of IDE's, a good one is very important. I finally settled for eric3. This one is Qt based making use of PyQt bindings (also SIP and Qscintilla). You have to realize that all IDE's practically bind you to one framework or another. I must say that being first rather gnome based, Qt turned out to be a superb environment, both under XP as under linux. In fact going from one to the other was absolutely effortless. You still will have to buy a Qt3 license for windows. A Qt4 free version is now available for windows, but I don't think that PyQt is ready for it. As of late, I installed eric3 on linux Suse 9.3 and was happily surprised to find out that I didn't have to bother with installing Qt, PyQt, etc. It was all there. Qt3 also turned out to be great with C/C++, which I'm not really using much, I admit. They also have an SQL module, includinc Sybase drivers. I have been using MySQL without Qt support using MySQLdb. -- http://mail.python.org/mailman/listinfo/python-list
pickling the objects returned by array.array()
Googling for "pickle array" in comp.lang.python yields old messages that show a PickleError -- plus one message where Alex Martelli writes "I am but an egg" :O) Looks like arrays are NOW (2.4.1) pickleable but not unpickleable -- see below. I appreciate that arrays are inherently not pickleable because of the type code. However: (1) Anyone know why/when the world changed? (2) If we had alternative constructors like array.iarray(contents) in parallel to array.array('i', contents), those objects could be pickled/unpickled -- yes/no? Cheers, John Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import pickle, array >>> class Foo(object): ...pass ... >>> foo = Foo() >>> foo.ia = array.array('i', [3,2,1]) >>> foo.ia array('i', [3, 2, 1]) >>> s = pickle.dumps(foo, -1) >>> bar = pickle.loads(s) Traceback (most recent call last): File "", line 1, in ? File "C:\Python24\lib\pickle.py", line 1394, in loads return Unpickler(file).load() File "C:\Python24\lib\pickle.py", line 872, in load dispatch[key](self) File "C:\Python24\lib\pickle.py", line 1097, in load_newobj obj = cls.__new__(cls, *args) TypeError: array() takes at least 1 argument (0 given) === -- http://mail.python.org/mailman/listinfo/python-list
Re: Extend Python
What is Qt? I have looked at PyQT and I can´t use it. I haven't tried it but the PyQT license makes the program useless. :( Any other suggestions? -- http://mail.python.org/mailman/listinfo/python-list
Re: OpenSource documentation problems
"Xah Lee" <[EMAIL PROTECTED]> writes: > I'm very sorry to say, that the Python doc is one of the worst possible > in the industry. [...] I suppose you are going to volounteer to fix it, then. Right? Asbjørn -- Asbjørn Sæbø, post.doc. Centre for Quantifiable Quality of Service in Communication Systems Norwegian University of Science and Technology http://www.q2s.ntnu.no/ > -- http://mail.python.org/mailman/listinfo/python-list
Re: OpenSource documentation problems
On 1 Sep 2005 05:04:33 -0700, Paul Boddie <[EMAIL PROTECTED]> wrote: > Please note that I'm not labelling you as a troll. No, he's simply barking mad. I was amused by a rec.arts.sf.written discussion [1] where Lee complains that Jonathan Swift (1667-1745)'s writing was unclear in style; apparently he's not aware that conventions and styles change over time. --amk [1] http://groups.google.com/group/alt.usage.english/msg/0ec9871395fc90d3 -- http://mail.python.org/mailman/listinfo/python-list
Re: Python doc problems example: gzip module
>> Constructor for the GzipFile class, which simulates most of the methods >> of a file object, with the exception of the readinto() and truncate() > > yeah, blab blab blab. what the fuck are you talking about? So, how to > use it? um... presumably you type "zippedfile = GzipFile(...)" and depending on whether you are creating a new file, or extracting an existing GzipFile. the documentation says: > The new class instance is based on fileobj, which can be a regular file, a > StringIO object, or any other object which simulates a file. It defaults to > None, in which case filename is opened to provide a file object." so i guess in your case you would want to do "zippedfile = GzipFile("myfile.gz")". >> When fileobj is not None, the filename argument is only used to be >> included in the gzip file header, which may includes the original >> filename of the uncompressed file. It defaults to the filename of >> fileobj, if discernible; otherwise, it defaults to the empty string, >> and in this case the original filename is not included in the header. > > what the fuck?? when you "gzip -d myfile.gz", the resultant output name might not be "myfile". The uncompressed name can be stored in the gzip header, and so if you provide both a fileobj argument and a filename argument to the GzipFile constructor, it will use fileobj for the data stream and just place filename into the header (as opposed to opening the file "filename"). >> The mode argument can be any of 'r', 'rb', 'a', 'ab', 'w', or 'wb', >> depending on whether the file will be read or written. The default is >> the mode of fileobj if discernible; otherwise, the default is 'rb'. If >> not given, the 'b' flag will be added to the mode to ensure the file is >> opened in binary mode for cross-platform portability. > > discernible? so, what the fuck are exactly these modes? can't you > describe them concretely? these are the same modes that are used in just about every single programming language when it comes to opening files. these modes are described in the Python tutorial and in the core Python documentation about files and file I/O. It should not be surprising, therefore, that GzipFile, which "simulates most of the methods of a file object", should have the same semantics when it comes to file modes. it is actually quite shocking to me that someone with 10 years of computing experience would not know what "rb" and "rb" mean in the context of opening files in a programming language. >> Calling a GzipFile object's close() method does not close fileobj, >> since you might wish to append more material after the compressed data. >> This also allows you to pass a StringIO object opened for writing as >> fileobj, and retrieve the resulting memory buffer using the StringIO >> object's getvalue() method. > > huh? append more material? pass a StringIO? and memory buffer? you see, not everyone who uses GzipFile will be decompressing files. sometimes they will be *compressing* file data. in this case, it's very possible that they want to compress data going over a network stream, or embed some gzipped into the middle of their own file format. GzipFile doesn't make any assumptions about what the user is going to do with the gzipped data or the file object that the Gzip module is writing into/reading from. > Motherfucking 90% of programers using this module really just want to > compress or decompress a file. I disagree. I think a whopping (non-motherfucking) 100% of programmers using this module want to compress or decompress file data. If someone just wants to decompress a file, wouldn't they just do: import os os.system("gzip -d filename.gz") The GzipFile module is meant to be used by folks who want to gzip or gunzip file data in a programmatic function. It's not meant to be a drop-in, shell-scripting replacement for the gzip command. -peter -- http://mail.python.org/mailman/listinfo/python-list
Re: graphical or flow charting design aid for python class development?
Thanks everyone. I will explore all the suggestions, but it looks like SPE is the immediate answer. Bill William Gill wrote: > Being somewhat new to Python, and having a tendency to over complicate > things in my class design, I was wondering if anyone can suggest a > simple graphical or flowcharting tool that they use to organize their > class and program design? Because of a 55 mph head-on accident a few > years back, I have short term memory problems, so flipping back and > forth between pages of code is next to impossible for me to keep > straight. A simple graphical model would allow me to 'see' everything > in one view, and better organize my resulting code. I have had limited > success using pydoc to view my classes, but it's not really much help in > development, just review, and sometimes there is too much info. > > I have used editors for other languages that allow the view to expand > and collapse functions/methods (like message threads here on the board), > which help, but I haven't seen anything like this for python. > > Thanks for any suggestions. > > Bill -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating custom event in WxPython
[EMAIL PROTECTED] a écrit : > Now when my socket thread detects an incoming message, I need my main > thread to interpret the message and react to it by updating the GUI. > IMO the best way to achieve this is by having my socket thread send a > custom event to my application's event loop for the main thread to > process. However, I'm at a total loss as far as creating custom events > is concerned. The WxWindows documentation isn't very helpful on this > either. I think this is what you're looking for: # begin code import wx wxEVT_INVOKE = wx.NewEventType() class InvokeEvent(wx.PyEvent): def __init__(self, func, args, kwargs): wx.PyEvent.__init__(self) self.SetEventType(wxEVT_INVOKE) self.__func = func self.__args = args self.__kwargs = kwargs def invoke(self): self.__func(*self.__args, **self.__kwargs) class MyFrame(wx.Frame): def __init__(self, *args, **kwargs): wx.Frame.__init__(self, *args, **kwargs) self.Connect(-1, -1, wxEVT_INVOKE, self.onInvoke) def onInvoke(self, evt): evt.invoke() def invokeLater(self, func, *args, **kwargs): self.GetEventHandler().AddPendingEvent(InvokeEvent(func, args, kwargs)) # end code This way, if frm is an instance of MyFrame, invoking frm.invokeLater(somecallable, arguments...) will invoke 'somecallable' with the specified arguments in the main GUI thread. I found this idiom somewhere on the Web and can't remember where. HTH -- http://mail.python.org/mailman/listinfo/python-list
Python 2.2.1 DLL extension causes "abnormal program termination"
Hello, Apologies if this has already been answered in here and I can't find it, but can anyone help with this problem? I hope the example code and comments state clearly enough what is happening, but if not, please ask me for further information. Thank in advance for any help. :-) Hugh #!/usr/bin/python # 1. DLL C++ source code # # #include # static PyObject* dummy(PyObject* self, PyObject* args) # { # return Py_None; # } # static PyMethodDef py_dll_test_methods[] = # { # { "dummy", dummy, METH_VARARGS, "dummy" }, # { 0,0,0,0 } # }; # extern "C" void _declspec(dllexport) initpy_dll_test(void) # { # (void) Py_InitModule("py_dll_test", py_dll_test_methods); # } # # 2. Build release DLL using MSVC++ version 6.0, linking with "python22.lib" # # 3. Copy DLL to "c:\python22\python\dll" directory # # 4. Python source import py_dll_test import time while 1: py_dll_test.dummy() time.sleep(0.01) # 5. Run python source # c:\>c:\Python22\python console_test.py # 6. Program runs for a while, but then crashes after 24 seconds with # abnormal program termination # Note. If I reduce the sleep time, the crash happens earlier. -- http://mail.python.org/mailman/listinfo/python-list
Error managment question (Trace Backs ?)
Hi This is a noob question, but here goes. I have a class that calls a function. class test: def __init__(self): if foo(): print "it worked" else: print "error" def foo(): some test returns 1 or 0 Now in other langs like C / C++ I catch the error in foo and report and exit. However I suspect in python that I can raise it and the class can catch it ? Guess I'm new to Traceback's ,etc Seeking Python Zen :) Marinus -- http://mail.python.org/mailman/listinfo/python-list
Re: OpenSource documentation problems
On Wed, 31 Aug 2005 19:57:00 GMT, Bryan Olson <[EMAIL PROTECTED]> wrote: > Since "help *is* pydoc.help, or at least...", the call could > show the same thing as help(pydoc.help), or at least inform the > user that more of the story is available from help(pydoc.help). But, given that the help message encourages the user to type help(), I don't think this odd corner case matters very much. > How about to fix the error? That's now done; I've struck the sentence from the CVS version, and pointed readers toward the zlib manual. --amk -- http://mail.python.org/mailman/listinfo/python-list
Re: Error managment question (Trace Backs ?)
"vpr" <[EMAIL PROTECTED]> wrote: > This is a noob question, but here goes. I have a class that calls a > function. > However I suspect in python that I can raise it and the class can catch > it ? the "errors and exceptions" chapter in the tutorial might be helpful: http://docs.python.org/tut/node10.html (especially sections 8.3 and 8.4) -- http://mail.python.org/mailman/listinfo/python-list
Re: OpenSource documentation problems
Steve Holden wrote: > Every page of the docs links to "About this document", which contains > the following: """If you are able to provide suggested text, either to > replace existing incorrect or unclear material, or additional text to > supplement what's already available, we'd appreciate the contribution. > There's no need to worry about text markup; our documentation team will > gladly take care of that.""" There is just one giant roadblock to that suggestion - Sourceforge requires a login to post bugs/patches. It doesn't seem like much, but as Paul Rubin mentioned, most people who find bugs/unclear passages in the docs aren't scanning the docs explicitly to edit them - they've uncovered the bug after working on some other project, and likely only after banging their head against the wall a few times trying to get it to work. If they have to go through the song and dance of signing up for another website to report the problem, they might just say "forget it." Sure, it's not hard to sign up for Sourceforge, but even a little barrier can stop you from contributing if you're not enthusiastic about it in the first place. Something a simple as allowing doc bugs to be submitted from a webform w/o login would reduce the barrier to contribute. - Increasing the size of the "About" text wouldn't hurt either. (To be honest, I've never noticed that text before, and it never occurred to me look at the "About" page for information on error reports.) That said, I think the Python manuals are great. But saying that they are perfect, or that the editing process couldn't be improved is just deluding yourself. -- http://mail.python.org/mailman/listinfo/python-list
Re: Well, Python is hard to learn...
wen wrote: > due to the work reason, i have to learn python since last month. i have > spent 1 week on learning python tutorial and felt good. but i still don't > understand most part of sourcecode of PYMOL(http://pymol.sourceforge.net/) > as before. Well, last time I checked, a good chunk of PyMol was written in C. Knowing Python may help you to learn C, but I doubt that one week is going to be sufficient. But I agree that Python is deceptive. It's so easy to learn and use, you can easily convince yourself you're a better programmer than you actually are. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.2.1 DLL extension causes "abnormal program termination"
Hugh wrote: > Apologies if this has already been answered in here and I can't find > it, but can anyone help with this problem? > I hope the example code and comments state clearly enough what is > happening, but if not, please ask me for further information. > Thank in advance for any help. > # static PyObject* dummy(PyObject* self, PyObject* args) > # { > # return Py_None; > # } C functions must return an "owned" reference. or in other words, since Py_None is an existing object, you need to increment the reference count before returning it: Py_INCREF(Py_None); return Py_None; or, better, but only works in recent Pythons: Py_RETURN_NONE; for more on reference counting and object ownership, see: http://docs.python.org/ext/refcounts.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Extend Python
SIP is not a commercial product and is released on a different license than PyQt. >From the SIP docs (http://www.river-bank.demon.co.uk/docs/sip/sipref.html#license) 1.1 License SIP is licensed under the same terms as Python itself. SIP places no restrictions on the license you may apply to the bindings you create. On a side note.. there will be a GPL edition of PyQt sometime in the future. http://www.riverbankcomputing.co.uk/pyqt/roadmap.php -- http://mail.python.org/mailman/listinfo/python-list
Re: OpenSource documentation problems
Rocco Moretti wrote: > Something a simple as allowing doc bugs to be submitted from a webform > w/o login would reduce the barrier to contribute. - Increasing the size > of the "About" text wouldn't hurt either. (To be honest, I've never > noticed that text before, and it never occurred to me look at the > "About" page for information on error reports.) the useredit approach I'm using over at the librarybook site works pretty well. for example, if you go to http://effbot.org/librarybook/mailbox.htm and click "suggest changes" at the bottom, you can edit the page source, preview the changes, and generate a patch when you're done, all without signing up or logging in. (unfortunately, Python's documentation is written in LaTeX, using a rather advanced tool chain to get from sources to HTML, so the librarybook approach won't really work "out of the box") -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.2.1 DLL extension causes "abnormal program termination"
Thank you very much. -- http://mail.python.org/mailman/listinfo/python-list
Re: OpenSource documentation problems
On Thu, 1 Sep 2005, Asbjørn Sæbø wrote: > I suppose you are going to volounteer to fix it, then. Right? I wish he'd just volunteer to shut up--permanently. -- Rich Teer, SCNA, SCSA, OpenSolaris CAB member President, Rite Online Inc. Voice: +1 (250) 979-1638 URL: http://www.rite-group.com/rich -- http://mail.python.org/mailman/listinfo/python-list
Re: OpenSource documentation problems
A.M. Kuchling wrote: > I was amused by a rec.arts.sf.written discussion [1] where Lee complains that > Jonathan Swift (1667-1745)'s writing was unclear in style; apparently he's > not aware > that conventions and styles change over time. Still, ill-founded assumptions about language could be much worse: http://www.wisdomquotes.com/000536.html Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Extend Python
Try looking at ctypes - http://starship.python.net/crew/theller/ctypes/ On 1 Sep 2005 05:12:21 -0700, [EMAIL PROTECTED] wrote: >Hi All I have a problem with extentions of Python. > >Background: >I'm workin within a large industrial control system and I have created >a Port for VxWorks. In the system we have different permissions >depending on which state the controller is in. To perform some actions >in some states may even injure or kill people. Therefor we need >"intelligent" wrappers between Python and C-code. > >My Question: >Swig offers some great features but is to basic for us. Is there >another program that creates more readble code that can be easily >edited? How much work is it to write our own wrappers? > >//T -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug in string.find
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > [slice] indices point to the "gap" between items, not to the items > themselves. > > positive indices start from the left end, negative indices from the > righept end. > > straight indexing returns the item just to the right of the given gap > (this is > what gives you the perceived assymmetry), slices return all items between > the given gaps. Well said. In some languages, straight indexing returns the item to the left instead. The different between items and gaps in seen in old terminals and older screens versus modern gui screens. Then, a cursur sat on top of or under a character space. Now, a cursur sits between chars. Terry J. Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: graphical or flow charting design aid for python class development?
There's also this about giving source/class browsers a hand by sprinkling "isinstance()"'s in http://wingware.com/doc/intro/tutorial-sassist-with-classes I always encourage people to write up their experience/improessions in the python wiki: http://wiki.python.org/moin/PythonEditors (or the separate IDE page) William Gill wrote: > Thanks everyone. I will explore all the suggestions, but it looks like > SPE is the immediate answer. > > Bill -- http://mail.python.org/mailman/listinfo/python-list
Re: Arguement error
Found the error. It was not in the code at all it has to do with the fact that the String module has a translate method and it was being used not the one I wrote. Thanks again.On 8/31/05, Terry Reedy <[EMAIL PROTECTED]> wrote: "Jeffrey Maitland" <[EMAIL PROTECTED]> wrote in messagenews:[EMAIL PROTECTED]Hello folks,>I am wondering why I am getting this error. when I try to run a script. >TypeError: translate() takes at most 3 arguments (10 given)Because you apparently gave it more than 3 args.>>> str.translate.__doc__'S.translate(table [,deletechars]) -> string\n\nReturn a copy of the string S, where all characters occurring in the optional argument deletechars areremoved, and the remaining characters have been mapped through the giventranslation table, which must be a string of length 256.' >but the thing is the method translate actually accepts 10 arguements.Why do you think that?Terry J. Reedy--http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug in string.find; was: Re: Proposed PEP: New style indexing,wasRe: Bug in slice type
"Stefan Rank" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > on 31.08.2005 16:16 Ron Adam said the following: >> The problem with negative index's are that positive index's are zero >> based, but negative index's are 1 based. Which leads to a non >> symmetrical situations. > > Hear, hear. > > This is, for me, the root of the problem. The root of the problem is the misunderstanding of slice indexes and the symmetry-breaking desire to denote an interval of length 1 by 1 number instead of 2. Someday, I may look at the tutorial to see if I can suggest improvements. In the meanwhile, see Fredrik's reply and my supplement thereto and the additional explanation below. > But changing the whole of Python to the (more natural and consistent) > one-based indexing style, for indexing from left and right, is... > difficult. Consider a mathematical axis |_|_|_|_|... 0 1 2 3 4 The numbers represent points separating unit intervals and representing the total count of intervals from the left. Count 'up' to the right is standard practice. Intervals of length n are denoted by 2 numbers, a:b, where b-a = n. Now consider the 'tick marks' to be gui cursor positions. Characters go in the spaces *between* the cursor. (Fixed versus variable space representations are irrelevant here.) More generally, one can put 'items' or 'item indicators' in the spaces to form general sequences rather than just char strings. It seems convenient to indicate a single char or item with a single number instead of two. We could use the average coordinate, n.5. But that is a nuisance, and the one number representation is about convenience, so we round down or up, depending on the language. Each choice has pluses and minuses; Python rounds down. The axis above and Python iterables are potentially unbounded. But actual strings and sequences are finite and have a right end also. Python then gives the option of counting 'down' from that right end and makes the count negative, as is standard. (But it does not make the string/sequence circular). One can devise slight different sequence models, but the above is the one used by Python. It is consistent and not buggy once understood. I hope this clears some of the confusion seen in this thread. Terry J. Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Is my thread safe from premature garbage collection?
Sion Arrowsmith wrote: > In article <[EMAIL PROTECTED]>, Benjamin Niemann <[EMAIL PROTECTED]> > wrote: >>[EMAIL PROTECTED] wrote: >>> However, in my current project I'm creating a bunch of threads which >>> are supposed to run until they've completed their run() method, and I'm >>> worried that if I do not keep references to these thread objects >>> around, the GC might happily delete them (and thereby kill my thread >>> routines maybe?) while they're not done yet. Is this fear justified? >>The threading module does already take care of keeping references to all >>running threads, > > The implementation of threading.enumerate() would be entertaining if it > didn't. > > Quite apart from which, I presume the OP's run() method looks something > like: > class MyThread(threading.Thread): > def run(self): > ... > So what is self if not a reference to the Thread object which is kept > around until run() has completed? This was just too obvious;) Looking at the sourcecode of the threading module and discovering the 'limbo' dict, where every thread stores a reference to itself, was certainly more entertaining. -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Code run from IDLE but not via double-clicking on its *.py
Dennis; Richie; >That sounds impossible, so I must be misunderstanding something. YOU - BOTH - UNDERSTAND ME ABSOLUTELY RIGHT! >1. >Start a new Command Prompt via Start / Programs / Accessories / Command >Prompt (or the equivalent on your machine) >2. >Type the following: d:\python23\python d:\python23\socket6.py [Enter] >3. Double-click your .vbs file in Windows Explorer. >Now what does the python Command Prompt say? It says... NOTHING! It just DISAPPEARS! JUST FOR TO MAKE SURE I put in the same directory (Python's root) testme.py file with this simplest content: print 'ONE' print 'TWO' print 'THREE' Then I run it EXACTLY the same way as I run socket6.py: D:\>python23\python d:\python23\testme.py [Enter] ONE TWO THREE D:\> AND OF COURSE CONSOLE WINDOW DID NOT CLOSE AFTER THAT ! BUT IT REALLY DISAPPEARS IN CASE OF socket6.py ! (but only AFTER I double-click my .vbs file in Windows Explorer) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Asynchronous I/O library (pyasynchio) [currently win-only]
> (but I'm not sure writing large if-else trees and state machines is that > much easier than implementing hook methods, Yes, but the decision about how exactly to do that is up to library user. I tried to build library which can be easily plugged into existing code w/o need for serious reengineering or changing design. Maybe there is a reason to build OO framework similar to asyncore on top of apoll class, I will consider it. > whether you know much > about programming or not. have you considered the case where you > want your program to handle *different* protocols? how do you > associate state with sockets in your programming model?) If there is a need to associate state with socket itself, it can be done with simple global dictionary, or one can use "act" (Asynchronous Completion Token) parameter (which defaults to None and is passed in completion dict) which is present in each of the methods which start asynch operation, it can be used to pass state information along (it may be even more convenient). > > (and why return dictionaries? wouldn't an ordinary object be a better > choice in this case? evt['type'] isn't really that pythonic compared to > evt.type. an attribute-based approach also lets you delay construction > of Python objects until the client code actually attempts to use it). Yes, you are right, I considered attribute-based approach, it will be used together with dictionary-based in future versions. As for delayed construction I do not think that there is a big deal in using it in this particular library. > > (and given that the users will have to check the type and success fields > for every single event, wouldn't it be better to return those as separate > values: "for op, ok, event in apoll.poll(): if op == '...': ...") Thanks, great idea. -- Sincerely, Vladimir Sukhoy -- http://mail.python.org/mailman/listinfo/python-list