Zope 3.2.0 released!
The Zope 3 development team is proud to announce Zope 3.2.0. Zope 3 is the next major Zope release and has been written from scratch based on the latest software design patterns and the experiences of Zope 2. It is our opinion that Zope 3 is more than ready for production use, which is why we decided to drop the 'X' for experimental from the name. We will also continue to work on making the transition between Zope 2 and Zope 3 as smooth as possible. As a first step, Zope 2.8 includes Zope 3 features in the form of Five. This is a long term effort. We're not there yet. **You can't run Zope 2 applications in Zope 3.** Downloads http://zope.org/Products/Zope3 Installation instructions for both Windows and Un*x/Linux are now available in the top level 'README.txt' file of the distribution. The binary installer is recommended for Windows. Zope 3.2 requires Python 2.4.2 to run. You must also have zlib installed on your system. Most Important Changes Since 3.1 - The ZServer has been replaced with the Twisted server. The Twisted server supports all that the ZServer supporting has well has HTTP over SSL natively and SFTP (disabled for now because of error handling problems). Also in the future it brings a better chance of other non-HTTP related protocols from being implemented for Zope3, like SMTP-in and IMAP. ZServer is still supported and will be used if you use the --zserver when you run mkzopeinstance. - Added a test browser. The test browser simulates a real Web browser as much as possible as a Python object. This allows us to write functional tests the same way the site would be experienced by the user. This greatly simplifies functional tests, makes documentation better and even helps analyzing usability. And of course, it can be used in functional doctests. - Changed the way returning large results is handled. The response.write method is no longer supported. Applications can now simply return files to the publisher. - Implemented the password managers proposal. Main idea beside the proposal is a standard way to implement password encoders/checkers, see zope.app.authentication.interfaces.IPasswordManager for details. + Added basic password managers: Plain Text, MD5, SHA1. + Support for password managers added for ZCML principals and principals saved in local PrincipalFolers. + Added bin/zpasswd command line script which helps to create ZCML principals. + Password managers support integrated into bin/mkzopeinstance. + New database generation created for convert local principals to new format. - Implemented the language namespace proposal. Now you can override the browser preferred language through the URL, like this: http://site.org/++lang++ru/path Note: If you want to use a custom IUserPreferredLanguages adapter and the '++lang++' feature together you should use zope.app.publisher.browser.CacheableBrowserLanguages adapter as a base class or at least as example. - Implemented a new object introspector. Instead of just providing information of the object's class, the new introspector focuses on providing information that is specific to the instance, such as directly provided interfaces and data, for example attribute values and annotation values. - Implemented the `devmode` switch for `zope.conf`. When turned on a ZCML feature called `devmode` is provided. Packages can then register functionality based on this feature. In Zope 3 itself, the devmode is used to only load the API doc is devmode; turning off the devmode thus closes a potential security hole and increases the start time by more than a second. - addMenuItem directive supports a `layer` attribute. - Added a re-implementation of i18n message IDs (now simply called ``Message``) that is immutable and thus can be treated like unicode strings with respect to security proxying. This implementation will replace the old one in upcoming versions. - Added test message catalog for testing i18n. If you specify ++lang++test in a URL, then all translated strings will be translated to [[domain][message_id], as in [[zope][Preview]]. Text without the domain marker isn't translated. For a complete list of changes see the 'CHANGES.txt' file. Resources - Zope 3 Development Web Site:http://dev.zope.org/Zope3 - Zope 3 Dev Mailing List:http://mail.zope.org/mailman/listinfo/zope3-dev - Zope 3 Users Mailing List:http://mail.zope.org/mailman/listinfo/zope3-users - IRC Channel: #zope3-dev at irc.freenode.net Acknowledgments Thanks goes to everyone that contributed. Enjoy! The Zope 3
PyCon TX 2006: Early-bird registration ends Jan. 15!
Early bird registration for PyCon TX 2006 ends on January 15th, so there's only a week left. To register, please go to: http://us.pycon.org/TX2006/Registration You can still register after Jan. 15th, but the cost will go up by US$65 (US$25 for students). This year PyCon will feature a day of tutorials before the three days of regular presentations. Course outlines for all the tutorials have been posted; see http://wiki.python.org/moin/PyCon2006/Tutorials All of the PyCon tutorials are still open for new registrations, but space is limited. Don't forget to book your hotel room, too. PyCon TX 2006 is being held at a Dallas/Addison hotel, and we have negotiated a special low rate of $79 plus applicable taxes: http://us.pycon.org/Addison/Hotels We hope to see you in Texas! Regards, A.M. Kuchling [EMAIL PROTECTED] Chair, PyCon 2006 http://us.pycon.org -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
PyCon: Plone, Python, BitTorrent keynotes
The keynotes at PyCon 2006 can now be announced. Alan Runyan and Alexander Limi will open the conference with a keynote about Plone. I haven't received a title yet, but I expect it will provide an overview of Plone's current status, how it's developed, and where the Plone project is headed. On the middle day of the conference (Saturday), Guido van Rossum will give his traditional State of Python talk that will presumably cover the new features that were introduced in Python 2.4 and the features coming in Python 2.5. On the final day, we'll have Bram Cohen, creator of BitTorrent. The format won't be a conventional keynote; instead, Cohen has requested to be interviewed. An interviewer hasn't been chosen yet, but you can suggest questions on a wiki page at http://wiki.python.org/moin/PyCon2006/BramCohenInterview. A.M. Kuchling [EMAIL PROTECTED] Chair, PyCon 2006 http://us.pycon.org -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: Try Python update
[EMAIL PROTECTED] (Alex Martelli) writes: Mike Meyer [EMAIL PROTECTED] wrote: For some reason, I couldn't see the links at the end of the page; now I can, though they look sort of ragged, but, OK. Probably the fonts I chose. I'm in no way a good visual designer. I'm hoping someone who is will step up to help with this. mike -- Mike Meyer [EMAIL PROTECTED] http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list
use browser setting for internet
Hi I have a problem with my script in python which uses xmlrpc. The script loses internet connection when it is used behind a firewall. I realize that the firewall is specified by using the http_proxy environment variable. However, the proxy server is automatically configured. I dont have access to its port or the IP. I have seen applications which have a select box to use the internet connection setting of the browser to connect to the web. I dont know how to access this connection setting in Python. Any help will be much appreciated.. -Wish -- http://mail.python.org/mailman/listinfo/python-list
how can I use socket.ssl in python
I am a newbie in using python. Today I try to use socket.ssl in a program. but python didn't support it. what's the reason? Anyone can tell me. -- http://mail.python.org/mailman/listinfo/python-list
Re: Copying files between different linux machines
Best is shfs. This uses the safety of ssh and allows you to mount filesystems on an external computer locally with commands like mount umount: shfsmount shfsumount. http://shfs.sourceforge.net/ malv -- http://mail.python.org/mailman/listinfo/python-list
Sockets on Windows and Mac
I am new to Python and have been writing some socket based programmes on Windows (with some success), however I am unable to get them to work on Mac. Are there differences in the way the socket module works on Windows and Mac? I would appreciate any simple code samples people my have for creating a very basic server on Macpython, I have copied code from various tutorials but as yet they don't appear to work. Thanks, rod -- http://mail.python.org/mailman/listinfo/python-list
Re: download full sites?
This isn't a Python question unless you are looking for a Python implementation. HTTrack is one that I have used in the past as a general purpose tool. http://www.httrack.com/ As for Python http://harvestman.freezope.org/ I have no experience with it. I just searched in the CheeseShop. -- http://mail.python.org/mailman/listinfo/python-list
Re: Viewing Binary Data
This recipe is a good place to start: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440528 Cheers Rich. -- http://mail.python.org/mailman/listinfo/python-list
Re: MVC programming with python (newbie) - please help
bwaha wrote: The author refers to mvctree.py in wxPython as an example of MVC design. However I'm still too green so I find that particular example too complex and I'm not understanding the separation the author is recommending. MVC is all about separation of concerns. The Model is responsible for managing the program's data (both private and client data). The View/Controller is responsible for providing the outside world with the means to interact with the program's client data. The Model provides an internal interface (API) to enable other parts of the program to interact with it. The View/Controller provides an external interface (GUI/CLI/web form/high-level IPC/etc.) to enable everything outwith the program to communicate with it. The Model is responsible for maintaining the integrity of the program's data, because if that gets corrupted then it's game over for everyone. The View/Controller is responsible for maintaining the integrity of the UI, making sure all text views are displaying up-to-date values, disabling menu items that don't apply to the current focus, etc. The Model contains no View/Controller code; no GUI widget classes, no code for laying out dialog boxes or receiving user input. The View/Controller contains no Model code; no code for validating URLs or performing SQL queries, and no original state either: any data held by widgets is for display purposes only, and merely a reflection of the true data stored in the Model. Now, here's the test of a true MVC design: the program should in essence be fully functional even without a View/Controller attached. OK, the outside world will have trouble interacting with it in that form, but as long as one knows the appropriate Model API incantations, the program will hold and manipulate data as normal. Why is this possible? Well, the simple answer is that it's all thanks to the low coupling between the Model and View/Controller layers. However, this isn't the full story. What's key to the whole MVC pattern is the _direction_ in which those connection goes: ALL instructions flow _from_ the View/Controller _to_ the Model. The Model NEVER tells the View/Controller what to do. Why? Because in MVC, while the View/Controller is permitted to know a little about the Model (specifically, the Model's API), but the Model is not allowed to know anything whatsoever about the View/Controller. Why? Because MVC is about creating a clear separation of concerns. Why? To help prevent program complexity spiralling out of control and burying you, the developer, under it. The bigger the program, the greater the number of components in that program. And the more connections exist between those components, the harder it is for developers to maintain/extend/replace individual components, or even just follow how the whole system works. Ask yourself this: when looking at a diagram of the program's structure, would you rather see a tree or a cat's cradle? The MVC pattern avoids the latter by disallowing circular connections: B can connect to A, but A cannot connect to B. In this case, A is the Model and B is the View/Controller. BTW, if you're sharp, you'll notice a problem with the 'one-way' restriction just described: how can the Model inform the View/Controller of changes in the Model's user data when the Model isn't even allowed to know that the View/Controller, never mind send messages to it? But don't worry: there is a solution to this, and it's rather neat even if it does seem a bit roundabout at first. We'll get back to that in a moment. In practical terms, then, a View/Controller object may, via the Model's API, 1. tell the Model to do things (execute commands), and 2. tell the Model to give it things (return data). The View/Controller layer *pushes instructions* to the Model layer and *pulls information* from the Model layer. And that's where your first MyCoolListControl example goes wrong, because the API for that class requires that information be *pushed* into it, so you're back to having a two-way coupling between layers, violating the MVC rules and dumping you right back into the cat's cradle architecture that you were [presumably] trying to avoid in the first place. Instead, the MyCoolListControl class should go with the flow, pulling the data it needs from the layer below, when it needs it. In the case of a list widget, that generally means asking how many values there are and then asking for each of those items in turn, because that's about the simplest and loosest way to do it and therefore keeps what coupling there is to a minimum. And if the widget wants, say, to present those values to the user in nice alphabetical order then that's its perogative; and its responsibility, of course. Now, one last conundrum, as I hinted at earlier: how do you keep the UI's display synchronised with the Model's state in an MVC-based system? Here's the problem: many View objects are stateful, e.g. a checkbox may be ticked or unticked, a text field may
Re: smtplib error('Connection reset by peer')
Van_Gogh [EMAIL PROTECTED] wrote: I am learning how to use the smtplib module, but am having some very early problems, maybe because I don't understand it. So, am I correct that by following the example in the Python: import smtplib server = smtplib.SMTP('localhost') server.sendmail('[EMAIL PROTECTED]', '[EMAIL PROTECTED]', To: [EMAIL PROTECTED] From: [EMAIL PROTECTED] Beware the Ides of March. ) server.quit() I should be able to send an email to the recipient, in this case [EMAIL PROTECTED] When I try to create the server(the line 'server = smtplib.SMTP('localhost')) I get the following error message: ... error: (10054, 'Connection reset by peer') Anyone got a pointer as to what I could do? Replace localhost with the name of your usual outgoing mail server. Although there ARE SMTP servers available for Windows XP, is it virtually certain that you aren't running one. -- - Tim Roberts, [EMAIL PROTECTED] Providenza Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Re: Returning Values from Bash Scripts
[EMAIL PROTECTED] wrote: How to execute bash scripts from python (other than using os.popen) and get the values that those bash scripts return. Why would you eliminate os.popen? It is precisely the right way to do this. That's the same interface bash itself uses to execute scripts. That is, assuming by values you mean the stdout from the script. If you really mean the numerical return code, you can use os.system. -- - Tim Roberts, [EMAIL PROTECTED] Providenza Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Re: Spelling mistakes!
On Sat, 07 Jan 2006 08:57:24 -0500, Peter Hansen [EMAIL PROTECTED] wrote: [British/American English] Hah! Canucks r00l! Most of those words look about equally good to us most of the time. (And it's not because of the beer!) (But our beer r00lz too.) And so does primairy, secondairy and similar frenchifications of English words, to some of you ... I'll think twice before agreeing to maintain software written by people from Montréal again. (Fortunately, that software was written in a static programming language.) /Jorgen -- // Jorgen Grahn grahn@Ph'nglui mglw'nafh Cthulhu \X/ snipabacken.dyndns.org R'lyeh wgah'nagl fhtagn! -- http://mail.python.org/mailman/listinfo/python-list
Re: Spelling mistakes!
On Fri, 6 Jan 2006 23:46:42 -0600, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I do tend to be a bit brief with my names and recognizing an identifier as an abbreviation don't bother me the way a misspelled word does. Maybe I've been using Unix systems for too long with their brief command names like mv and grep. I like to think of it as everybody else having spent too /little/ time with Unix systems ;-) /Jorgen -- // Jorgen Grahn grahn@Ph'nglui mglw'nafh Cthulhu \X/ snipabacken.dyndns.org R'lyeh wgah'nagl fhtagn! -- http://mail.python.org/mailman/listinfo/python-list
Re: os.environ['PATH'] missing
On 6 Jan 2006 06:03:05 -0800, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: ... How can it not be present? What might cause this seemingly random situation? Well, it's not uncommon to start a program with a reduced set of environment variables, including a limited, hardcoded $PATH, so something like os.system(ls) cannot be tricked to run an ls outside the system-controlled, safe directories. On my machine, env -i sh starts a shell without $PATH. Bash seems to default to a builtin search path in that situation (/bin and /usr/bin, I suppose). But reducing $PATH is one thing (and fairly common); removing it is another. And I'm not sure that programs are expected to cope with the absence of $PATH; just because it's /possible/ to remove it doesn't mean it's legal. I don't know anything about web servers and Zope. Sorry. /Jorgen -- // Jorgen Grahn grahn@Ph'nglui mglw'nafh Cthulhu \X/ snipabacken.dyndns.org R'lyeh wgah'nagl fhtagn! -- http://mail.python.org/mailman/listinfo/python-list
Re: Spelling mistakes!
[EMAIL PROTECTED] enlightened us with: I'm one of those people who, for better or worse, is a good speller. Words just look right or wrong to me and it bothers me when they look wrong. Same here. I have to use code that has childs instead of children... I also can't stand then vs than mixups... And what's up with using Google to check for spelling? I have a dictionary for that, works a lot better! Sybren -- The problem with the world is stupidity. Not saying there should be a capital punishment for stupidity, but why don't we just take the safety labels off of everything and let the problem solve itself? Frank Zappa -- http://mail.python.org/mailman/listinfo/python-list
Re: Sockets on Windows and Mac
rodmc wrote: I am new to Python and have been writing some socket based programmes on Windows (with some success), however I am unable to get them to work on Mac. Please elaborate on unable to get them to work. What problems do you see? In my experience, there is no difference with the Mac. I'm using a mac (with OS X tiger) myself. --Irmen -- http://mail.python.org/mailman/listinfo/python-list
Re: Are there anybody using python as the script engine for ASP?
[EMAIL PROTECTED] wrote: Hi everyone, I'm planning using python with asp, and wonder if some people do use python/asp in real life projects. (I'm going to) cheers, === kychan Guys at my company do. I think there were some issues which they either worked around or that went away after an upgrade. I'm not sure. But we're running live web sites with it right now, as far as I know. -- Dale Strickland-Clark Riverhall Systems - www.riverhall.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: Viewing Binary Data
Cuyler wrote: Hello, I would like to display a file in its binary form (1s and 0s), but I'm having no luck... Any thoughts would be most appreciated. Cheers! Cuyler You may consider to check out the latest by me started thread in this newsgroup with the subject: Does Python allow access to some of the implementation details?, which surprizingly deals mainly with getting bits out of strings and integers and provides appropriate code. Claudio -- http://mail.python.org/mailman/listinfo/python-list
Re: how can I use socket.ssl in python
ascetic wrote: I am a newbie in using python. Today I try to use socket.ssl in a program. but python didn't support it. what's the reason? Anyone can tell me. (1) Search the newsgroup; several people sometimes have it. (2) Ask smart questions. Try to imagine answering what you just asked with the evidence you provided. I don't know if you are writing in Jython, IronPython, CPython, ... on a dingleblat 4000, running python 2.1.35? ... --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie with some doubts.
On Sat, 07 Jan 2006 18:47:20 -0500, Mike Meyer [EMAIL PROTECTED] wrote: ... As far as I'm concerned, the definitive work in this area is Meyer's Object Oriented Software Construction. He covers pretty much all the uses of OO language features, using a language that was designed specifically to support those uses. Bjarne Stroustrup recommends it, but notes Tends to confuse Eiffel with universal principles. Be warned that after reading it, you're liable to come back to Python and wonder Why doesn't Python do X. Meyer is too much of a fundamentalist for me, so much of the book just pisses me off. I expect that many Python programmers would feel the same way, Python being the way it is. It's still worth reading though -- especially the part on design by contract. And all his vicious attacks on things you happen to dislike, too ;-) /Jorgen -- // Jorgen Grahn grahn@Ph'nglui mglw'nafh Cthulhu \X/ snipabacken.dyndns.org R'lyeh wgah'nagl fhtagn! -- http://mail.python.org/mailman/listinfo/python-list
Re: Returning Values from Bash Scripts
On Sun, 08 Jan 2006 08:57:01 GMT, Tim Roberts [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: How to execute bash scripts from python (other than using os.popen) and get the values that those bash scripts return. Why would you eliminate os.popen? It is precisely the right way to do this. That's the same interface bash itself uses to execute scripts. That is, assuming by values you mean the stdout from the script. If you really mean the numerical return code, you can use os.system. And that's just one value, of course. And not a very useful one, either -- it's a non-negative integer, with a pretty low max value -- 255 on my machine. Unless you count the crash return codes. /Jorgen -- // Jorgen Grahn grahn@Ph'nglui mglw'nafh Cthulhu \X/ snipabacken.dyndns.org R'lyeh wgah'nagl fhtagn! -- http://mail.python.org/mailman/listinfo/python-list
Re: C regex equiv to Python implementation?
On 6 Jan 2006 11:24:14 -0800, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Ganesan, I'm trying to stay portable between Windows and Linux. My app will run on Linux when deployed. But we do a lot of simulation on Windows because of better dev tools available on Windows. (Lots of people seem to do so, and I can't understand why. I tend to translate that to we're not comfortable with working on our target platform ...) So I really want a regular expression implementation that'll compile under MS VS 2003 C++ and also under Gnu C++ for Linux on both x86 and ARM targets. Read the parent posting again. He recommended PCRE as the best compatible solution. It would surprise me /a lot/ if that didn't compile on Windows. /Jorgen -- // Jorgen Grahn grahn@Ph'nglui mglw'nafh Cthulhu \X/ snipabacken.dyndns.org R'lyeh wgah'nagl fhtagn! -- http://mail.python.org/mailman/listinfo/python-list
Re: Spelling mistakes!
Sybren And what's up with using Google to check for spelling? I have a Sybren dictionary for that, works a lot better! A couple things: 1. It's generally faster than reaching for the dictionary. 2. The hit count for a word and its misspelling gives me some measure of how the rest of the online English-speaking world thinks that word is spelled. 3. Some recent words like podcast aren't in the now ancient dictionary on my shelf. Other words have gained new meanings since my dictionary was published. Okay, so that's a few things... wink Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: - E04 - Leadership! Google, Guido van Rossum, PSF
Alex Martelli wrote: Anton Vredegoor [EMAIL PROTECTED] wrote: However I still maintain that I was never able to meet these fine people you speak about and which you seem to know because the cost involved (a few hundred euro to visit pycon for example) was too high compared to my food budget. Europython is cheap to attend, and has been held twice in Charleroi, Belgium, for example -- if you're in the Netherlands, you could have bycicled there, crashed with somebody (I've seen lots of impecunious people offered hospitality that way), and not spent more on food than you would by staying in the Netherlands. You'll have to invent some better excuse, to explain why you chose not to attend it. I already sent some reply via google, got a server error, resent, got a confirmation that my message was posted, but it doesn't show up and also there's no way to retrieve my message except fishing in the cache? Yesterday I had a post not showing up (in another group) but today it was there. This makes me feel insecure enough about whether or not my replies come through via google to start using another provider. It's not like I'm on a secret google no fly list no? (slightly paranoic) Anyway, I'm not typing all that again. Maybe it will show up tomorrow. The gist of it is that for me a few hundred euros is and was a *lot* of money, and that this talk about 'cheap to attend' irritates me a lot. Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie Question: CSV to XML
On Fri, 6 Jan 2006, ProvoWallis wrote: Hi! Would anyone be willing to give me some feedback about this little script that I wrote to convert CSV to XML. I'll happily admit that I still have a lot to learn about Python so I'm always grateful for constructive feedback. I have started using a module called Amara for xml manipulation. I am pleased with how elegant it is, compared to what I have used before. Catalin -- == We are what we repeatedly do. Excellence, therefore, is not an act but a habit. == -- http://mail.python.org/mailman/listinfo/python-list
Re: question about mutex.py
[EMAIL PROTECTED] wrote: yes, I read it, and I even know about threading's existence. I just thought that if something claims to be atomic, it better should be. I think the term atomic is meaningful only when the context is known. For example, atomic operations in the Python interpreter are certainly not atomic within the larger context of the CPU, and atomic CPU operations are not necessarily atomic in the context of a system with multiple CPUs. If the context for mutex.py explicitly excludes multi-threading then you have to interpret atomic in whatever context that defines. -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Viewing Binary Data
Cuyler wrote: I would like to display a file in its binary form (1s and 0s), but I'm having no luck... Any thoughts would be most appreciated. I'm sure the list archives (visible via Google Groups and other means) has answers to similar questions in the past. Also the online Python CookBook probably has at least one recipe that would help. Have you tried searching online at all? -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Sockets on Windows and Mac
rodmc wrote: I am new to Python and have been writing some socket based programmes on Windows (with some success), however I am unable to get them to work on Mac. Are there differences in the way the socket module works on Windows and Mac? I would appreciate any simple code samples people my have for creating a very basic server on Macpython, I have copied code from various tutorials but as yet they don't appear to work. Aren't you basing this on the standard library modules such as SocketServer, or extension packages like Twisted, that already do most of the work for you? If you were, you likely wouldn't have to deal with any such Mac-specific problems (if that's really what they are) and you would likely save yourself a whole heck of a lot of time reinventing the wheel too. (Note also that most people doing raw socket programming do it wrong, which is a good reason to jump straight ahead to build on the work of others.) -Peter -- http://mail.python.org/mailman/listinfo/python-list
What is the UI Element to work with HTML Content
Hi All, I am a newbie to Python. I want to know that there is any UI Control to browse HTML pages. Please let me know. If that is available, I am planing to develop a Chat application. Waiting for help.Thanks, Satish. [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] Send instant messages to your online friends http://in.messenger.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
XML RFC Server
Hi All,Is there any example code to develop XML RFC Web Service in Python.Thanks, Satish.Send instant messages to your online friends http://in.messenger.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
Re: - E04 - Leadership! Google, Guido van Rossum, PSF
Anton Vredegoor [EMAIL PROTECTED] wrote: ... Europython is cheap to attend, and has been held twice in Charleroi, Belgium, for example -- if you're in the Netherlands, you could have ... The gist of it is that for me a few hundred euros is and was a *lot* of money, and that this talk about 'cheap to attend' irritates me a lot. I just don't understand, always assuming you're in the Netherlands, how attending Europython in Belgium (as opposed to Pycon in the US) could have cost hundreds of euros. Conference registration is free to speakers, bicycling NL-BE not costly (many were driving from NL, so bumming a ride was far from impossible either), many attendants arranged to crash for free thanks to the hospitality of others, food costs in Belgium aren't much different from those in NL. I'm not saying a few hundred euros is 'cheap' -- it obviously isn't, if your income is low to nonexistent; rather, I'm wondering where that hundreds amount comes from. You originally mentioned only pycon (where the need to fly to the US, for people living in Europe, can obviously account for hundreds of euros already); Europython is specifically held in Europe to be cheaper and more convenient to attend for Europeans, and I've always met many people there who fell in the income low to nonexistent bracket for one reason or another. Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: Try Python update
Mike Meyer [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] (Alex Martelli) writes: Mike Meyer [EMAIL PROTECTED] wrote: For some reason, I couldn't see the links at the end of the page; now I can, though they look sort of ragged, but, OK. Probably the fonts I chose. I'm in no way a good visual designer. I'm hoping someone who is will step up to help with this. I'm finding it hard to arrange my own experiments with Safari (I'm using a loaner machine since my normal one[s] are all having problems and under repair) but I'm told the solution for cursor positioning is to set the caretPos attribute of the textarea, like for example at http://www.codingforums.com/showthread.php?t=43245 ... Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: Sockets on Windows and Mac
rodmc [EMAIL PROTECTED] wrote: I am new to Python and have been writing some socket based programmes on Windows (with some success), however I am unable to get them to work on Mac. Are there differences in the way the socket module works on Windows and Mac? I would appreciate any simple code samples people my have for creating a very basic server on Macpython, I have copied code from various tutorials but as yet they don't appear to work. Assuming you mean the MacOS X which has been current, in one version or another, for the last few years (I don't know anything about ancient OS's such as MacOS 9 etc), I've personally tested all the socket programming examples from the Nutshell on MacOS X 10.3 and 10.4 (Panther and Tiger), and they do, of course, run just fine. You can download the zipfile with all the examples of Python in a Nutshell from the O'Reilly site, even if you don't own the book, and try them. Of course, you must run a server and one or more client from different Terminal windows -- that's about the only important (but totally obvious) precaution you should take. I don't think you can set the Mac's firewall to impede communication within the localhost, but I admit I haven't tried -- so, if you have any problem, detach your Mac from any networks and then in System Preferences disable the firewall entirely (and make sure your Mac doesn't erroneously believe it DOES have external networks, i.e., only networking is to/from '127.0.0.1', the local host, AKA the loopback or 'lo0' interface). If you STILL have problems after that, copy and paste the output of ifconfig, it should start something like: lo0: flags=8049UP,LOOPBACK,RUNNING,MULTICAST mtu 16384 inet 127.0.0.1 netmask 0xff00 and also any current messages from an instance of Applications/Utilities/Console -- as well of course as error messages and tracebacks, if any, from your Python scripts, but I think any problem must result from some weird issue with system settings rather than any programming issue. Do remember to copy and paste, NOT summarize in your own words, otherwise you may make it unfeasible for us to help you out! Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: MVC programming with python (newbie) - please help
has wrote: MVC is all about separation of concerns This is a wonderful explanation of MVC. I'm going to keep a link to the Google-Groups version just so I can cite it to those asking about MVC. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
PIL.Image.frombuffer/string ... who do data using?
hello again everyone! I'm writing a wrapper for tif file that parse its and return the data image in this way below : self.fp.seek(StripOffsets) data = self.fp.read(StripByteCounts) return data where: self.fp is a file object StripOffsets is a offset position of image StripByCounts is extend of image after we get a data, now to set its in PIL.Image.fromstring(...) but ( evely! :) ), returned this error follow: ValueError not enough image data why??? Should I to convert data in other format??? any suggestion? Thanks and regard. Ivan -- http://mail.python.org/mailman/listinfo/python-list
Re: Viewing Binary Data
Cuyler wrote: I would like to display a file in its binary form (1s and 0s), but I'm having no luck... Any thoughts would be most appreciated. If you are on a UNIX system, or on Windows with Cygwin, you can use the 'od' command to dump a file in hex or octal. man od od -Ax -tx1 -- http://mail.python.org/mailman/listinfo/python-list
Re: Viewing Binary Data
On 6 Jan 2006 09:15:50 -0800, Cuyler [EMAIL PROTECTED] wrote: Hello, I would like to display a file in its binary form (1s and 0s), but I'm having no luck... Any thoughts would be most appreciated. What have you tried? having no luck doesn't tell us much, although it is a phrase previously seen in use ;-/ Is this homework? If the first character were 'C' what order would you like to see the bits? (e.e., 111 (big-endian l-r) vs 111 (little-endian l-r) Do you want to convert the whole file like a hex dump, except binary? Want to give a clue as to output format? Gapped? Ascii at the right? Bit numbers or hex byte offsets at the left? Do you need a one-liner solution? Regards, Bengt Richter -- http://mail.python.org/mailman/listinfo/python-list
Re: Spelling mistakes!
On Sun, 8 Jan 2006 08:58:48 -0600 [EMAIL PROTECTED] wrote: Sybren And what's up with using Google to check for spelling? I have a Sybren dictionary for that, works a lot better! A couple things: 1. It's generally faster than reaching for the dictionary. But not faster than use a dict server! Why not just use (e.g.) kdict? That's what I do. It's got to be at least as accurate as Google, and much more likely to give me the right answer. 2. The hit count for a word and its misspelling gives me some measure of how the rest of the online English-speaking world thinks that word is spelled. This is useful for words that don't really exist. Or rather, that do exist, but are not documented. ;-) 3. Some recent words like podcast aren't in the now ancient dictionary on my shelf. Other words have gained new meanings since my dictionary was published. Same comment -- Google is good as a backup, but I'd much rather use a dictionary to look up words than a search engine. Wikipedia is another good resource for newer words, brand names, jargon, and slang. BTW, one of the most common programming spelling errors is deprecate versus depreciate -- I wonder how many people actually realize that both words exist, but have entirely different meanings? deprecate means to be declared unworthy or no longer to be used by an authority and is pronounced de-pre-KATE, while depreciate means to go down in financial value and is pronounced de-PRE-she-ATE. An awful lot of people seem to think that deprecate is a misspelling of depreciate and then correct the spelling. But then, they must have a funny idea of what it means when a software feature is deprecated. Maybe they think it's like the opposite of appreciate or something? (We don't appreciate your code anymore). ;-) I suppose some smart alec is going to argue that it goes down in value because an authority declared it unworthy. Would be about par for the course. ;-) -- Terry Hancock ([EMAIL PROTECTED]) Anansi Spaceworks http://www.AnansiSpaceworks.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Viewing Binary Data
Paul Watson wrote: Cuyler wrote: I would like to display a file in its binary form (1s and 0s), but I'm having no luck... Any thoughts would be most appreciated. If you are on a UNIX system, or on Windows with Cygwin, you can use the 'od' command to dump a file in hex or octal. man od od -Ax -tx1 And if you're on a Linux system and have KDE loaded, use the KHexEdit utility. KHexEdit can display the file in hexadecimal, decimal, octal, binary or text format, swap endians, search, filter, etc. It's a very sweet utility. -- http://mail.python.org/mailman/listinfo/python-list
Multiway Branching
I need to look at two-byte pairs coming from a machine, and interpret the meaning based on the relative values of the two bytes. In C I'd use a switch statement. Python doesn't have such a branching statement. I have 21 comparisons to make, and that many if/elif/else statements is clunky and inefficient. Since these data are coming from an OMR scanner at 9600 bps (or faster if I can reset it programmatically to 38K over the serial cable), I want a fast algorithm. The data are of the form: if byte1 == 32 and byte2 == 32: row_value = 0 elif byte1 == 36 and byte2 == 32: row_value = natural ... elif byte1 == 32 and byte2 == 1: row_value = 5 elif byte1 == 66 and byte2 == 32: row_value = 0.167 There are two rows where the marked response equates to a string and 28 rows where the marked response equates to an integer (1-9) or float of defined values. Suggestions appreciated. Rich -- Richard B. Shepard, Ph.D. | Author of Quantifying Environmental Applied Ecosystem Services, Inc. (TM) | Impact Assessments Using Fuzzy Logic http://www.appl-ecosys.com Voice: 503-667-4517 Fax: 503-667-8863 -- http://mail.python.org/mailman/listinfo/python-list
Re: Multiway Branching
[EMAIL PROTECTED] wrote: I need to look at two-byte pairs coming from a machine, and interpret the meaning based on the relative values of the two bytes. In C I'd use a switch statement. Python doesn't have such a branching statement. I have 21 comparisons to make, and that many if/elif/else statements is clunky and inefficient. Since these data are coming from an OMR scanner at 9600 bps (or faster if I can reset it programmatically to 38K over the serial cable), I want a fast algorithm. The data are of the form: if byte1 == 32 and byte2 == 32: row_value = 0 elif byte1 == 36 and byte2 == 32: row_value = natural ... elif byte1 == 32 and byte2 == 1: row_value = 5 elif byte1 == 66 and byte2 == 32: row_value = 0.167 There are two rows where the marked response equates to a string and 28 rows where the marked response equates to an integer (1-9) or float of defined values. DATA_MAP = { chr(32)+chr(32): 0, chr(36)+chr(32): natural, ... chr(32)+chr(1): 5, chr(66)+chr(32): 0.167, } ... row_value = DATA_MAP[source.read(2)] # or: row_value = DATA_MAP.get(source.read(2), DEFAULT) /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Spelling mistakes!
Chris F.A. Johnson wrote: On 2006-01-08, Terry Hancock wrote: BTW, one of the most common programming spelling errors is deprecate versus depreciate -- I wonder how many people actually realize that both words exist, but have entirely different meanings? The words overlap in meaning. Both can mean to disparage or belittle. Some dictionaries give 'depreciate' as a definition of 'deprecate'. Well if someone told me my investments were deprecated I'd take that differently to them being depreciated. -- Robin Becker -- http://mail.python.org/mailman/listinfo/python-list
Re: Spelling mistakes!
On 2006-01-08, Terry Hancock wrote: BTW, one of the most common programming spelling errors is deprecate versus depreciate -- I wonder how many people actually realize that both words exist, but have entirely different meanings? The words overlap in meaning. Both can mean to disparage or belittle. Some dictionaries give 'depreciate' as a definition of 'deprecate'. -- Chris F.A. Johnson, author |http://cfaj.freeshell.org Shell Scripting Recipes: | My code in this post, if any, A Problem-Solution Approach | is released under the 2005, Apress | GNU General Public Licence -- http://mail.python.org/mailman/listinfo/python-list
Re: question about mutex.py
On Sun, 08 Jan 2006 10:24:43 -0500, Peter Hansen [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: yes, I read it, and I even know about threading's existence. I just thought that if something claims to be atomic, it better should be. I think the term atomic is meaningful only when the context is known. For example, atomic operations in the Python interpreter are certainly not atomic within the larger context of the CPU, and atomic CPU operations are not necessarily atomic in the context of a system with multiple CPUs. If the context for mutex.py explicitly excludes multi-threading then you have to interpret atomic in whatever context that defines. Atomic means trademarked by a company that used to use that name in the 50's to describe and identify a line toys it put in its breakfast cereal boxes. The rights are now owned by an IP scavenging company which is trying to sell them for stock in another IP scavenger with more money left, so be careful. There's also some related talk of a patent on a method of using semiotic elements in association with the distribution of digital generic products to make them distinguishable for any business purpose whatever. IP principles established with corn flakes and decoder rings are thought to translate perfectly to the digital domain of FOSS distros including anything toy-like. Regards, Bengt Richter -- http://mail.python.org/mailman/listinfo/python-list
What is the slickest way to transpose a square list of lists (tuple of tuples)?
My way is ugly. These has to be a better way. Thanks, Gerard -- http://mail.python.org/mailman/listinfo/python-list
Re: Multiway Branching
On 8 Jan 2006 18:59:28 GMT, [EMAIL PROTECTED] wrote: I need to look at two-byte pairs coming from a machine, and interpret the meaning based on the relative values of the two bytes. In C I'd use a switch statement. Python doesn't have such a branching statement. I have 21 comparisons to make, and that many if/elif/else statements is clunky and inefficient. Since these data are coming from an OMR scanner at 9600 bps (or faster if I can reset it programmatically to 38K over the serial cable), I want a fast algorithm. The data are of the form: if byte1 == 32 and byte2 == 32: row_value = 0 elif byte1 == 36 and byte2 == 32: row_value = natural ... elif byte1 == 32 and byte2 == 1: row_value = 5 elif byte1 == 66 and byte2 == 32: row_value = 0.167 There are two rows where the marked response equates to a string and 28 rows where the marked response equates to an integer (1-9) or float of defined values. Suggestions appreciated. Set up a dict to map your byte pairs to values, e.g., pairvalues = dict([ ... ((32,32), 0), ... ((36,32), natural), ... # ... ... ((32, 1), 5), ... ((66,32), 0.167) ... ]) Then you can access the values like: row_value = pairvalues.get((36,32), 'default') row_value 'natural' The .get method allows you to specify a default, in case you get an unexpected pair. You could also use pairvalues[(byte1,byte2)] and catch the KeyError exception for unexpected pairs. for byte1, byte2 in (66,32), (32,1), (36,32), (32,32), (20,20): ... print '%10s = %r' %((byte1,byte2), pairvalues.get((byte1,byte2), 'DEFAULT ??')) ... (66, 32) = 0.16701 (32, 1) = 5 (36, 32) = 'natural' (32, 32) = 0 (20, 20) = 'DEFAULT ??' HTH Regards, Bengt Richter -- http://mail.python.org/mailman/listinfo/python-list
decorator question
hello NG, consider this code def timelogger(f): ... def wrapper(*a,**kw): ... print started at %s % time.ctime() ... t0 = time.time() ... f(*a, **kw) ... t1 = time.time() ... print ended at %s % time.ctime() ... print diff = , t1-t0, sec ... return wrapper ... import time @timelogger ... def loops(a,b,c): ... sum = 0 ... for i in range(a): ... for j in range(b): ... for k in range(c): ... sum += 1 ... loops function wrapper at 0x402eec34 loops(10,10,10) started at Sun Jan 8 23:19:19 2006 ended at Sun Jan 8 23:19:19 2006 diff = 0.000367164611816 sec the code above works fine but I am wondering wheather it's possible to write something like this def timelogger(f, logfile=sys.stdout): ... def wrapper(*a,**kw): ... logfile.write(started at %s % time.ctime()) ... t0 = time.time() ... f(*a, **kw) ... t1 = time.time() ... logfile.write(ended at %s % time.ctime()) ... logfile.write(diff = %f %s % (t1-t0, sec)) ... return wrapper import time @timelogger(file(hierher, a)) ### (1) ... def loops(a,b,c): ... sum = 0 ... for i in range(a): ... for j in range(b): ... for k in range(c): ... sum += 1 ... (1) fails to compile is it possible to pass parameters to a decorator function? Regards, Daniel -- http://mail.python.org/mailman/listinfo/python-list
Re: Returning Values from Bash Scripts
Jorgen Grahn [EMAIL PROTECTED] writes: On Sun, 08 Jan 2006 08:57:01 GMT, Tim Roberts [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: How to execute bash scripts from python (other than using os.popen) and get the values that those bash scripts return. Why would you eliminate os.popen? It is precisely the right way to do this. That's the same interface bash itself uses to execute scripts. That is, assuming by values you mean the stdout from the script. If you really mean the numerical return code, you can use os.system. And that's just one value, of course. And not a very useful one, either -- it's a non-negative integer, with a pretty low max value -- 255 on my machine. Unless you count the crash return codes. Further, os.system (and os.popen) pass the command through a shell, and actually gives you the return value from the shell instead of the command in question. Normally, these are the same thing. But if the shell fails to execute the command, they aren't - and there's no easy way to tell that that's what happened. mike -- Mike Meyer [EMAIL PROTECTED] http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list
Re: Multiway Branching
On Sun, 8 Jan 2006 20:31:49 +0100, Fredrik Lundh [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: I need to look at two-byte pairs coming from a machine, and interpret the meaning based on the relative values of the two bytes. In C I'd use a switch statement. Python doesn't have such a branching statement. I have 21 comparisons to make, and that many if/elif/else statements is clunky and inefficient. Since these data are coming from an OMR scanner at 9600 bps (or faster if I can reset it programmatically to 38K over the serial cable), I want a fast algorithm. The data are of the form: if byte1 == 32 and byte2 == 32: row_value = 0 elif byte1 == 36 and byte2 == 32: row_value = natural ... elif byte1 == 32 and byte2 == 1: row_value = 5 elif byte1 == 66 and byte2 == 32: row_value = 0.167 There are two rows where the marked response equates to a string and 28 rows where the marked response equates to an integer (1-9) or float of defined values. DATA_MAP = { chr(32)+chr(32): 0, chr(36)+chr(32): natural, ... chr(32)+chr(1): 5, chr(66)+chr(32): 0.167, } ... row_value = DATA_MAP[source.read(2)] # or: row_value = DATA_MAP.get(source.read(2), DEFAULT) Much better than my version, since you went beyond the OP's code to what he said he was trying to do (look at two-byte pairs coming from a machine ... over the serial cable). I just went for a direct translation of the code, which is nearly always a mistake. I should know better. I guess I do, since I always rant about requirements ;-/ Also don't know why I chose to use dict([]) vs {}, since there's no bare key names to clean the quotes off of. Oh well. Regards, Bengt Richter -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie with some doubts.
Jorgen Grahn [EMAIL PROTECTED] writes: On Sat, 07 Jan 2006 18:47:20 -0500, Mike Meyer [EMAIL PROTECTED] wrote: ... As far as I'm concerned, the definitive work in this area is Meyer's Object Oriented Software Construction. He covers pretty much all the uses of OO language features, using a language that was designed specifically to support those uses. Bjarne Stroustrup recommends it, but notes Tends to confuse Eiffel with universal principles. He does tend to write like the Eiffel way of doing OO is the only valid way of doing OO. Be warned that after reading it, you're liable to come back to Python and wonder Why doesn't Python do X. Meyer is too much of a fundamentalist for me, so much of the book just pisses me off. I expect that many Python programmers would feel the same way, Python being the way it is. I should note that Python isn't Eiffel is often a good answer to the questions Why doesn't Python do X that arise from that book. The design goals of Eiffel are different from the design goals of Python. I like the design goals of both languages, so I like both languages. mike -- Mike Meyer [EMAIL PROTECTED] http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list
Re: Returning Values from Bash Scripts
Steven D'Aprano wrote: How to execute bash scripts from python (other than using os.popen) and get the values that those bash scripts return. The easy way is to call it with subprocess.call. import subprocess Traceback (most recent call last): File stdin, line 1, in ? ImportError: No module named subprocess It might be easy, but an awful lot of people won't be using a version of Python that has the subprocess module, and for them upgrading may not be easy (or even possible) at all. subprocess is available as a separate distribution for Python 2.2 and newer: http://www.lysator.liu.se/~astrand/popen5/ if you're on a unixoid system, all you need is the subprocess.py file, which you can also get directly from the Python SVN: http://svn.python.org/view/python/trunk/Lib/subprocess.py /F -- http://mail.python.org/mailman/listinfo/python-list
Re: decorator question
Schüle Daniel wrote: (1) fails to compile is it possible to pass parameters to a decorator function? Yes, I think this does what you want: import time, sys def timelogger(logfile=sys.stdout): def actual_timelogger(function): def wrapper(*a,**kw): logfile.write(started at %s % time.ctime()) t0 = time.time() function(*a, **kw) t1 = time.time() logfile.write(ended at %s % time.ctime()) logfile.write(diff = %f %s % (t1-t0, sec)) return wrapper return actual_timelogger @timelogger(logfile=file(hierher, a))### (1) def loops(a,b,c): sum = 0 for i in range(a): for j in range(b): for k in range(c): sum += 1 loops(100,100,100) Cheers, Frank -- http://mail.python.org/mailman/listinfo/python-list
Re: decorator question
Schüle Daniel schrieb: hello NG, consider this code def timelogger(f): ... def wrapper(*a,**kw): ... print started at %s % time.ctime() ... t0 = time.time() ... f(*a, **kw) ... t1 = time.time() ... print ended at %s % time.ctime() ... print diff = , t1-t0, sec ... return wrapper ... import time @timelogger ... def loops(a,b,c): ... sum = 0 ... for i in range(a): ... for j in range(b): ... for k in range(c): ... sum += 1 ... loops function wrapper at 0x402eec34 loops(10,10,10) started at Sun Jan 8 23:19:19 2006 ended at Sun Jan 8 23:19:19 2006 diff = 0.000367164611816 sec the code above works fine but I am wondering wheather it's possible to write something like this def timelogger(f, logfile=sys.stdout): ... def wrapper(*a,**kw): ... logfile.write(started at %s % time.ctime()) ... t0 = time.time() ... f(*a, **kw) ... t1 = time.time() ... logfile.write(ended at %s % time.ctime()) ... logfile.write(diff = %f %s % (t1-t0, sec)) ... return wrapper import time @timelogger(file(hierher, a))### (1) ... def loops(a,b,c): ... sum = 0 ... for i in range(a): ... for j in range(b): ... for k in range(c): ... sum += 1 ... (1) fails to compile is it possible to pass parameters to a decorator function? It's possible. The call to timelogger must return a function which itself takes a function and returns one: def timelogger(logfile=sys.stdout): def deco(f): def wrapper(*a,**kw): logfile.write(started at %s % time.ctime()) t0 = time.time() f(*a, **kw) t1 = time.time() logfile.write(ended at %s % time.ctime()) logfile.write(diff = %f %s % (t1-t0, sec)) return wrapper return deco Regards, Daniel -- http://mail.python.org/mailman/listinfo/python-list
Re: Spelling mistakes!
On 2006-01-08, Robin Becker wrote: Chris F.A. Johnson wrote: On 2006-01-08, Terry Hancock wrote: BTW, one of the most common programming spelling errors is deprecate versus depreciate -- I wonder how many people actually realize that both words exist, but have entirely different meanings? The words overlap in meaning. Both can mean to disparage or belittle. Some dictionaries give 'depreciate' as a definition of 'deprecate'. Well if someone told me my investments were deprecated I'd take that differently to them being depreciated. That's why I said overlap, not that they are the same. -- Chris F.A. Johnson, author |http://cfaj.freeshell.org Shell Scripting Recipes: | My code in this post, if any, A Problem-Solution Approach | is released under the 2005, Apress | GNU General Public Licence -- http://mail.python.org/mailman/listinfo/python-list
Re: Display of JPEG images from Python
I remember seeing somewhere saying that the wx.StaticBitmap is only for small image (64x64?), is that true?On 6 Jan 2006 07:01:24 -0800, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: You can f.i. use wxPython (www.wxPython.org). Here is a compact andugly, but (almost) minimal, example of a python script that shows animage file:import wxa = wx.PySimpleApp ()wximg = wx.Image('img.jpg',wx.BITMAP_TYPE_JPEG)wxbmp=wximg.ConvertToBitmap()f = wx.Frame(None, -1, Show JPEG demo)f.SetSize( wxbmp.GetSize() )wx.StaticBitmap(f,-1,wxbmp,(0,0))f.Show(True) def callback(evt,a=a,f=f):# Closes the window upon any keypressf.Close()a.ExitMainLoop()wx.EVT_CHAR(f,callback)a.MainLoop()-svein-- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: What is the slickest way to transpose a square list of lists (tuple of tuples)?
Gerard Brunick said unto the world upon 08/01/06 01:27 PM: My way is ugly. These has to be a better way. Thanks, Gerard If you'd posted your way, I might well have seen if I could do it in a nicer fashion. But, since for all I know, my best efforts would result in the approach you already have, I'm unlikely to put the effort in. I suspect I'm not alone. You might do well to show the approach you are unhappy with. Best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list
Re: What is the slickest way to transpose a square list of lists (tuple of tuples)?
Gerard Brunick wrote: My way is ugly. These has to be a better way. Thanks, Gerard Ugly is not necessary not the slickest. To do better, there must be something to compare to, right? Claudio -- http://mail.python.org/mailman/listinfo/python-list
Re: What is the slickest way to transpose a square list of lists (tuple of tuples)?
Brian van den Broek wrote: Gerard Brunick said unto the world upon 08/01/06 01:27 PM: My way is ugly. These has to be a better way. Thanks, Gerard If you'd posted your way, I might well have seen if I could do it in a nicer fashion. But, since for all I know, my best efforts would result in the approach you already have, I'm unlikely to put the effort in. I suspect I'm not alone. You might do well to show the approach you are unhappy with. Indeed. And it would also make it obvious what you're trying to do as I'm not completely convinced I understand your description. However, if my guess is correct: transposed = zip(*listoflists) is probably hard to beat. -tim -- http://mail.python.org/mailman/listinfo/python-list
Re: Spelling mistakes!
1. It's generally faster than reaching for the dictionary. Terry But not faster than use a dict server! Why not just use (e.g.) Terry kdict? Maybe because not everybody has it? % kdict -bash: kdict: command not found Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Help Please: 'module' object has no attribute 'compile'
Oh, no I did not create any modules, wish I had the knowledge to do so! I think I've moved beyond whatever that issue was and now getting a timeout. The info is below... any help you can give is appreciate! I'm running this code... import os, re, string, urllib, types data = urllib.urlencode({'control_device': 'Kitchen Lights=on'}) urllib.urlopen('http://192.168.1.11', data) and get this error log from Python... File Q:\python\python23.zlib\urllib.py, line 78, in urlopen File Q:\python\python23.zlib\urllib.py, line 183, in open File Q:\python\python23.zlib\urllib.py, line 297, in open_http File Q:\python\python23.zlib\httplib.py, line 712, in endheaders File Q:\python\python23.zlib\httplib.py, line 597, in _send_output File Q:\python\python23.zlib\httplib.py, line 564, in send File Q:\python\python23.zlib\httplib.py, line 548, in connect IOError : [Errno socket error] (10060, 'Operation timed out') Kent Johnson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] livin wrote: I beleive so... I cannot know for sure becasue the models are not separate... they are in the python23.zlib file... I'm no sure how to check the file, it looks as if it is compiled (I'm new to python so forgive my ignorance) Yes, there should be an re module in your Python distribution, and it should have a compile attribute. You can check this from the python intepreter easily: import re re.compile function compile at 0x008FE0B0 What I am suggesting is that YOU may have created a module named re that Python is finding instead of the system module by that name. In this case your module doesn't have a compile attribute. This would cause the error you see. Kent Kent Johnson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] livin wrote: my log... INFO urllib.urlopen('http://192.168.1.11/hact/kitchen.asp', urllib.urlencode({'Action': 'hs.ExecX10ByName+Kitchen+Lights%2C+On %2C+100x=4y=6'})) INFO INFO File Q:\python\python23.zlib\urllib.py, line 78, in urlopen INFO File Q:\python\python23.zlib\urllib.py, line 159, in open INFO File Q:\python\python23.zlib\urllib.py, line 957, in splittype INFO AttributeError INFO : INFO 'module' object has no attribute 'compile' That line reads _typeprog = re.compile('^([^/:]+):') Do you have a module named 're' that is shadowing the library module of the same name? Kent -- http://mail.python.org/mailman/listinfo/python-list
Re: use browser setting for internet
Wish [EMAIL PROTECTED] writes: Hi I have a problem with my script in python which uses xmlrpc. The script loses internet connection when it is used behind a firewall. I realize that the firewall is specified by using the http_proxy environment variable. However, the proxy server is automatically configured. I dont have access to its port or the IP. I have seen applications which have a select box to use the internet connection setting of the browser to connect to the web. I dont know how to access this connection setting in Python. Any help will be much appreciated.. What OS? On Windows, urllib.getproxies() should get you the info you need if IE is correctly configured (and both urllib and urllib2 use this -- though the @ syntax is somewhat broken in urllib2, IIRC). Disclaimer: I never seem to have to jump through any proxy or auth hoops recently, so I'm not very reliable on this... John -- http://mail.python.org/mailman/listinfo/python-list
Re: Multiway Branching
On 2006-01-08, Fredrik Lundh [EMAIL PROTECTED] wrote: DATA_MAP = { chr(32)+chr(32): 0, chr(36)+chr(32): natural, ... chr(32)+chr(1): 5, chr(66)+chr(32): 0.167, } ... row_value = DATA_MAP[source.read(2)] # or: row_value = DATA_MAP.get(source.read(2), DEFAULT) Thank you, Fredrik. That's ideal, and a great lesson for a newcomer to Python. Rich -- Richard B. Shepard, Ph.D. | Author of Quantifying Environmental Applied Ecosystem Services, Inc. (TM) | Impact Assessments Using Fuzzy Logic http://www.appl-ecosys.com Voice: 503-667-4517 Fax: 503-667-8863 -- http://mail.python.org/mailman/listinfo/python-list
Tkinter GTK in the same application?
I need to use tkinter.canvas in a gtk application. Is that any possible. I guess I should use threads: is there any example of how to start the 2 mainloops? Thanks for any possible hint sandro *:-) -- Sandro Dentella *:-) http://www.tksql.orgTkSQL Home page - My GPL work -- http://mail.python.org/mailman/listinfo/python-list
Re: Calling foreign functions from Python? ctypes?
Martin v. Löwis wrote: Paul Watson wrote: I need to call GetVersionInfo() and handle VERSIONINFO information. I thought that distutils might have something, but I do not see it yet. Any suggestions? You could write this specific API in VB, and then run cscript.exe in a pipe; or you could write a wrapper module just for that specific API (in case PythonWin is too large for you). I cannot find any way to get to GetVersionInfo in VBScript (cscript). If so, this appears to leave me with no choice but to produce a Windows executable, whether a .exe or C code wrapped from Python. Right? -- http://mail.python.org/mailman/listinfo/python-list
Re: how-to POST form data to ASP pages?
Any ideas on how to troubleshoot the 'Operation timed out' error, or work-around it? I'm just sending a POST to a windows-based web server (non-IIS). thanks! livin livin@@cox.net wrote in message news:[EMAIL PROTECTED] Dennis, Alan, Mike... help? According to the HomeSeer (I'm trying to trigger events on the HomeSeer application) documentation I do not need to use ASP. The simple HTTP command should be accepted directly from a HTML page. Here's the page in the online manual for Homeseer with the info: HomeSeer info on Controlling Devices from HTML - http://www.homeseer.com/support/homeseer/WebHelp/web_access/controlling_devices_and_events_from_your_own_pages.htm I appreciate the assistance. livin livin@@cox.net wrote in message news:[EMAIL PROTECTED] The library is the PC version of 2.3 --- I have done some more testing. I simplified my .py to only 2 lines... import urllib urllib.urlopen('http://192.168.1.11', urllib.urlencode({'control_device': 'Kitchen Lights=off'})) I get this error... File Q:\python\python23.zlib\urllib.py, line 78, in urlopen File Q:\python\python23.zlib\urllib.py, line 183, in open File Q:\python\python23.zlib\urllib.py, line 297, in open_http File Q:\python\python23.zlib\httplib.py, line 712, in endheaders File Q:\python\python23.zlib\httplib.py, line 597, in _send_output File Q:\python\python23.zlib\httplib.py, line 564, in send File Q:\python\python23.zlib\httplib.py, line 548, in connect IOError : [Errno socket error] (10060, 'Operation timed out') I've taken the commands I'm using from working HTTP ASP pages. Here's actual code from an HTML page I'm using for the same device I'm trying in my .PY... form method=post td nowrap class=tableroweven a name=bm83274/a input type=hidden name=bookmark value=83274 input type=hidden name=ref_page value=stat input type=hidden name=control_device value=Kitchen Lights input class=formbutton type=submit name=action_on value=On input class=formbutton type=submit name=action_off value=Off select class=formdropdown name=selectdim SIZE=1 onchange=SubmitForm(this) option selected value=00%/option option value=1010%/option option value=2020%/option option value=3030%/option option value=4040%/option option value=5050%/option option value=6060%/option option value=7070%/option option value=8080%/option option value=9090%/option option value=100100%/option /select /td/form Dennis Lee Bieber [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Sun, 1 Jan 2006 12:35:06 -0700, livin livin@@cox.net declaimed the following in comp.lang.python: IOError : [Errno socket error] (10057, 'Socket is not connected') That doesn't look like anything to do, directly, with parameter encodings... Rather, it looks like your server is closing the connection unexpectedly. You've got the Python source for everything down to the call to sendall, examine it -- it might help figure out where things are failing. (sendall looks to be in a compiled module) -- == [EMAIL PROTECTED] | Wulfraed Dennis Lee Bieber KD6MOG [EMAIL PROTECTED] | Bestiaria Support Staff == Home Page: http://www.dm.net/~wulfraed/ Overflow Page: http://wlfraed.home.netcom.com/ -- http://mail.python.org/mailman/listinfo/python-list
project-like or plan extension?
I'd like to find a plan or project-like extension to use in a PyGtk application. I need very basic functionaluties: time-zooming, possibility to set tooltip for objects, possibility to move around chunks of a job. Any ideas? TIA sandro -- Sandro Dentella *:-) http://www.tksql.orgTkSQL Home page - My GPL work -- http://mail.python.org/mailman/listinfo/python-list
Re: decorator question
On Sun, 08 Jan 2006 23:26:28 +0100, =?ISO-8859-1?Q?Sch=FCle_Daniel?= [EMAIL PROTECTED] wrote: [...] the code above works fine but I am wondering wheather it's possible to write something like this def timelogger(f, logfile=sys.stdout): ... def wrapper(*a,**kw): ... logfile.write(started at %s % time.ctime()) ... t0 = time.time() ... f(*a, **kw) ... t1 = time.time() ... logfile.write(ended at %s % time.ctime()) ... logfile.write(diff = %f %s % (t1-t0, sec)) ... return wrapper import time @timelogger(file(hierher, a)) ### (1) ... def loops(a,b,c): ... sum = 0 ... for i in range(a): ... for j in range(b): ... for k in range(c): ... sum += 1 ... (1) fails to compile is it possible to pass parameters to a decorator function? Yes, but then the function must return the same kind of thing a bare decorator-function name would have, which is a function able to take a single argument of a function and return a function. So your decorator won't take f as an argument, just the optional logfile, and it will return a function that does the wrapping like the original decorator. import sys, time def timelogger(logfile=sys.stdout): ...def deco(f): ...def wrapper(*a,**kw): ...logfile.write(started at %s\n % time.ctime()) ...t0 = time.time() ...f(*a, **kw) ...t1 = time.time() ...logfile.write(ended at %s\n % time.ctime()) ...logfile.write(diff = %f %s\n % (t1-t0, sec)) ...return wrapper ...return deco ... @timelogger() # stdout ... def foo(): pass ... foo() started at Sun Jan 08 14:13:55 2006 ended at Sun Jan 08 14:13:55 2006 diff = 0.00 sec foo() started at Sun Jan 08 14:14:02 2006 ended at Sun Jan 08 14:14:02 2006 diff = 0.00 sec @timelogger() # stdout ... def foo(dt): time.sleep(dt) ... foo(5) started at Sun Jan 08 14:14:59 2006 ended at Sun Jan 08 14:15:04 2006 diff = 5.007000 sec foo(.5) started at Sun Jan 08 14:15:16 2006 ended at Sun Jan 08 14:15:17 2006 diff = 0.501000 sec Regards, Bengt Richter -- http://mail.python.org/mailman/listinfo/python-list
2D canvas for GTK
I need a (decent) canvas for PyGTK. I used tkinter.canvas with real pleasure in the past but now I need to use the canvas in a Gtk application. Does anybody know of one with similar capabilities? It must work on Windows too. It must be able to produce postscript output. Thanks sandro *:-) -- Sandro Dentella *:-) http://www.tksql.orgTkSQL Home page - My GPL work -- http://mail.python.org/mailman/listinfo/python-list
Re: What is the slickest way to transpose a square list of lists (tuple of tuples)?
On Sun, 08 Jan 2006 15:21:59 -0600, Brian van den Broek [EMAIL PROTECTED] wrote: Gerard Brunick said unto the world upon 08/01/06 01:27 PM: My way is ugly. These has to be a better way. Thanks, Gerard If you'd posted your way, I might well have seen if I could do it in a nicer fashion. But, since for all I know, my best efforts would result in the approach you already have, I'm unlikely to put the effort in. I suspect I'm not alone. You might do well to show the approach you are unhappy with. OTOH, he's probably just trying to get someone to remember zip-abuse for him. Hope it's not homework ;-) sq = [[r+c for c in 'abc'] for r in '123'] for r in sq: print r ... ['1a', '1b', '1c'] ['2a', '2b', '2c'] ['3a', '3b', '3c'] for r in (zip(*sq)): print r ... ('1a', '2a', '3a') ('1b', '2b', '3b') ('1c', '2c', '3c') Regards, Bengt Richter -- http://mail.python.org/mailman/listinfo/python-list
Re: decorator question
thx to all now I understand how it works and why it should be done in this way so it's possible to write more than only one declarator def foo(f): ... l = [1] ... def method(*a,**kw): ... f(l, *a, **kw) ... return method ... def bar(f): ... l = [2] ... def method(*a,**kw): ... f(l, *a, **kw) ... return method ... @foo ... @bar ... def foobar(x,y,z): ... print x ... print y ... print z ... foobar(1) [2] [1] 1 x and y are already binded by the way .. to l's lists are considered to be in closure? Or what is the right denotation for them? Can someone give me some pointers to the metaprogramming in Python? links etc Regards, Daniel -- http://mail.python.org/mailman/listinfo/python-list
Re: Calling foreign functions from Python? ctypes?
Paul Watson wrote: I cannot find any way to get to GetVersionInfo in VBScript (cscript). Well, in VB6, you have ctypes. So you can call any API function you like to. For one implementation, see http://www.andreavb.com/tip030020.html Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: building Python 2.4.2 on Mac OS X
Vidar Gundersen wrote: are there any easy to understand instructions for building Python on Mac OS X Tiger? It should work out of the box. are there any prerequisites that i have missed? my ./configure make stops here: You should pass --with-suffix=.exe to configure, or else you get a file name conflict on HFS. Python/mactoolboxglue.c:462: warning: return makes integer from pointer without a cast make: *** [Python/mactoolboxglue.o] Error 1 This might be where it stops, but it is not the cause of the error. Can you please look up a bit further in the output to see what command fails? Or else, can you post the entire make output? Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: building Python 2.4.2 on Mac OS X
Vidar Gundersen wrote: are there any easy to understand instructions for building Python on Mac OS X Tiger? are there any prerequisites that i have missed? my ./configure make stops here: Python/mactoolboxglue.c:462: warning: return makes integer from pointer without a cast make: *** [Python/mactoolboxglue.o] Error 1 did you try googling for distinct portions of the error message ? here's the first hit http://www.opendarwin.org/pipermail/darwinports/2005-November/029138.html (note that the problem here is a missing include file, as shown by the error messages at the top) here's a followup message with the fix: http://www.opendarwin.org/pipermail/darwinports/2005-November/029146.html /F -- http://mail.python.org/mailman/listinfo/python-list
Re: PyHtmlGUI Project is looking for developers
Paul Boddie [EMAIL PROTECTED] writes: [...] many would advocate using AJAX techniques and dropping support for conventional Web interactions, but I think that such advocacy and the resulting applications threaten the usability of the Web for fairly large groups of people. That may well be true in practice, but I don't see any intrinsic reason for it. Do you {,care}? John -- http://mail.python.org/mailman/listinfo/python-list
total newb here
I've bought a few books on the topic, but I'm a total newb to programming in general. I've got about 4 years PHP / MySQL experience, but none with actual programming. To be honest, I don't even really know what Python is used for. I'm thought I would start here and see if anyone knew of good places to start for someone as green as I. And now I'm off to google. Thanks in advance. Greg -- http://mail.python.org/mailman/listinfo/python-list
Newline at EOF Removal
I am looking for a way to strip the blank line and the empty newline at the end of the text file. I can get the blank lines removed from the file but it always leaves the end line (which is blank) as a newline. My code is here and it works but leaves the newline at the end of the file. How do I get rid of it? import re f = open(oldfile.txt) w = open(newfile.txt, wt) for line in f.readlines(): line = re.sub(r'^\s+$', '', line) w.write(line) w.close() I have tried everything I know and still falling short. Any help? -- http://mail.python.org/mailman/listinfo/python-list
Re: Multiway Branching
[EMAIL PROTECTED] wrote: inefficient. Since these data are coming from an OMR scanner at 9600 bps (or faster if I can reset it programmatically to 38K over the serial cable), I want a fast algorithm. It depends on your actual environment, of course, but 38kbps is usually not considered fast today - given a modern CPU (or even one from a few years back), 21 (or 42) short string comparisons in an interprated language should be trivially fast. (I'm not saying that using a different approach such as dictionaries isn't good because of other reasons :) ) -- http://mail.python.org/mailman/listinfo/python-list
Re: total newb here
Try www.awaretek.com/plf.html for online help learning Python. -- http://mail.python.org/mailman/listinfo/python-list
Re: Spelling mistakes!
Terry Hancock ([EMAIL PROTECTED]) writes: BTW, one of the most common programming spelling errors is deprecate versus depreciate -- I wonder how many people actually realize that both words exist, but have entirely different meanings? That's a common spelling error, yes, but.. The number-one spelling error among today's semi-literates is writing it's for the third-person neuter possessive instead of its. (These folks frequently write her's instead of hers and who's instead of whose as well, but, strangely, hardly ever write hi's for the masculine form.) A native English speaker's spelling of its is a very accurate measure of his general literacy. [Gee, I hope their were no spelling misteaks inn that paragraph...] -- Walt -- http://mail.python.org/mailman/listinfo/python-list
Re: psexec and os.popen help
[EMAIL PROTECTED] wrote: popen3 did the trick. Use the modules subprocess ... it solves many problems, including the problem of too many similar functions. :-) These functions (execl, execv, popen, popen2, popen3, ...) are relicts from C and very unpythonic. It's IMHO always a better programming style to use subprocess. Greets, Volker -- Volker Grabsch ---(())--- \frac{\left|\vartheta_0\times\{\ell,\kappa\in\Re\}\right|}{\sqrt [G]{-\Gamma(\alpha)\cdot\mathcal{B}^{\left[\oint\!c_\hbar\right]}}} -- http://mail.python.org/mailman/listinfo/python-list
Re: PIL.Image.frombuffer/string ... who do data using?
ivan.dm wrote: I'm writing a wrapper for tif file that parse its and return the data image in this way below : self.fp.seek(StripOffsets) data = self.fp.read(StripByteCounts) return data ... after we get a data, now to set its in PIL.Image.fromstring(...) but ( evely! :) ), returned this error follow: ValueError not enough image data Why are you doing it this way instead of just using Image.open()? PIL already knows how to read and convert TIFF images... -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: question about mutex.py
Bengt Richter wrote: Atomic means trademarked by a company that used to use that name in the 50's to describe and identify a line toys it put in its breakfast cereal boxes. The rights are now owned by an IP scavenging company which is trying to sell them for stock in another IP scavenger with more money left, so be careful. There's also some related talk of a patent on a method of using semiotic elements in association with the distribution of digital generic products to make them distinguishable for any business purpose whatever. IP principles established with corn flakes and decoder rings are thought to translate perfectly to the digital domain of FOSS distros including anything toy-like. And, thus, the origin of an area where I often work with Python: cereal communications... (to tastefully blend the spelling errors thread with this one ;-) ) -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Double Click mouse event problems
Thank you very much. Adding in a timer delay is a good fake out. I guess I always considered a double-click to be one distinct behavior aside from the single click. I have rarely seen where a double-click action engaged an object without single clicks to select the object. For example, the Window's file manager allows you to Ctrl-click select two files and double click to launch both files. So I don't expect distinct behaviors from Button-1-Down and Button-1-Up, but I guess I do expect them from a double and single click. No matter, I'll try the delay. This should work reasonably well. -- http://mail.python.org/mailman/listinfo/python-list
Re: Newline at EOF Removal
Alex Nordhus wrote: I am looking for a way to strip the blank line and the empty newline at the end of the text file. I can get the blank lines removed from the file but it always leaves the end line (which is blank) as a newline. My code is here and it works but leaves the newline at the end of the file. How do I get rid of it? import re f = open(oldfile.txt) w = open(newfile.txt, wt) for line in f.readlines(): line = re.sub(r'^\s+$', '', line) w.write(line) w.close() I have tried everything I know and still falling short. Any help? If you want to remove all blank lines at the end of the file, but leave a single newline following the last non-blank line, this might be the simplest thing to try: w.write(f.read().rstrip('\n') + '\n') Of course, that requires reading in all the data in one swell foop, but that's usually not a problem. It also technically fails in the special case of a file that has only blank lines (since it will result in a file with a single newline) but your specification is ambiguous about what you want to do in that case anyway. This also depends on the definition of blank being empty line, which might not be how you define it. Are you trying to remove lines that contain only whitespace? (Note that whitespace is usually considered to include \x20\r\n\t\f\v.) -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Try Python update
[EMAIL PROTECTED] (Alex Martelli) writes: I'm finding it hard to arrange my own experiments with Safari (I'm using a loaner machine since my normal one[s] are all having problems and under repair) but I'm told the solution for cursor positioning is to set the caretPos attribute of the textarea, like for example at http://www.codingforums.com/showthread.php?t=43245 ... caretPos is apparently an MS extension; it's not supported by Safari or the Gecko browsers. setSelectionRange is the standards-compliant version. It's not supported by Safari either :-(. Thanks, mike -- Mike Meyer [EMAIL PROTECTED] http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list
Re: Newline at EOF Removal
Alex Nordhus [EMAIL PROTECTED] writes: I am looking for a way to strip the blank line and the empty newline at the end of the text file. I can get the blank lines removed from the file but it always leaves the end line (which is blank) as a newline. My code is here and it works but leaves the newline at the end of the file. This really isn't a very clear description of the problem. Does your file end with two newlines in row? That would be what you'd get if it ended with the newline for the last line. If it ends with just one newline, then you're not getting the a blank last line, you're simply getting a last line that ends with a newline. How do I get rid of it? import re f = open(oldfile.txt) w = open(newfile.txt, wt) for line in f.readlines(): line = re.sub(r'^\s+$', '', line) w.write(line) This is an abuse of regular expressions (see http://www.mired.org/home/mwm/spare/ ); simple string methods can do this job for you. Try: for line in f: if line.strip(): w.write(line) mike -- Mike Meyer [EMAIL PROTECTED] http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list
Re: 2D canvas for GTK
Sandro Dentella [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I need a (decent) canvas for PyGTK. I used tkinter.canvas with real pleasure in the past but now I need to use the canvas in a Gtk application. Does anybody know of one with similar capabilities? It must work on Windows too. It must be able to produce postscript output. I think that PyCairo might be what you're looking for, at least if you're using gtk 2.8. -- http://mail.python.org/mailman/listinfo/python-list
Re: Try Python update
Mike Meyer [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] (Alex Martelli) writes: I'm finding it hard to arrange my own experiments with Safari (I'm using a loaner machine since my normal one[s] are all having problems and under repair) but I'm told the solution for cursor positioning is to set the caretPos attribute of the textarea, like for example at http://www.codingforums.com/showthread.php?t=43245 ... caretPos is apparently an MS extension; it's not supported by Safari or the Gecko browsers. setSelectionRange is the standards-compliant version. It's not supported by Safari either :-(. Meanwhile, other JS/DOM experts have told me that there's NO way to set cursor position within a textarea according to w3c standards. In this case, what your site does now may be the least bad approach, and that fact might be noted in the browsers subpage, together with a request for anybody who has other ideas to submit them, I guess. Sorry for wasting your time, I'm still having trouble believing that the standards didn't bother to specify SOME way to perform such an elementary functionality. Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: PyQt Access Violations
Hope this post doesn't duplicate, as a Google Groups error happened last attempt... Phil Thompson wrote: What version of Qt? Phil It's version 2.3.0 non-commerical for Windows. My OS is Windows 2000 Professional SP4. Using this same version of Qt for a Ruby-based implementation of a similar app I didn't experience the access violation crashes when invoking the setCentralWidget() method. It's sporadic, as the crashes sometimes take 2-3 widget opens/closes to happen. Other times it takes more. Trying to debug the crashes the script never makes it past this method. Here's an excerpt from the Dr. Watson error log: function: QGList::findRef 39d2dd42 807c240800 cmp byte ptr [esp+0x8],0x0 ss:00c09513=00 39d2dd47 7407 jz QString::fromUtf8+0x8a (39d36850) FAULT -39d2dd49 8b4108 mov eax,[ecx+0x8] ds:00cd9f51=48001500 39d2dd4c 33d2 xor edx,edx 39d2dd4e eb06 jmp QString::fromUtf8+0x90 (39d36856) 39d2dd50 8b4110 mov eax,[ecx+0x10] ds:00cd9f51=48001500 39d2dd53 8b5114 mov edx,[ecx+0x14] ds:00cd9f51=48001500 39d2dd56 56 pushesi 39d2dd57 85c0 testeax,eax 39d2dd59 740e jz QString::fromLatin1+0xb (39d36869) 39d2dd5b 8b30 mov esi,[eax] ds:007ad4d8=00858340 39d2dd5d 3b742408 cmp esi,[esp+0x8] ss:00c09513= 39d2dd61 7406 jz QString::fromLatin1+0xb (39d36869) 39d2dd63 8b4008 mov eax,[eax+0x8] ds:012873be= * Stack Back Trace * FramePtr ReturnAd Param#1 Param#2 Param#3 Param#4 Function Name 0012F664 1E057D56 089FE908 00857948 0001 088FAAD0 !QGList::findRef 0012F6C8 0001 007A5234 00779288 !PyCFunction_Call -- http://mail.python.org/mailman/listinfo/python-list
Building Pywin32 source code?
Has anyone been able to access the source code for Pywin32 at sourceforge? I have been able to use TortouseCVS to access other CVS projects,but with the Pywin32 cvs site, I can not log in. Sam Schulenburg -- http://mail.python.org/mailman/listinfo/python-list
Real-world use cases for map's None fill-in feature?
Proposal I am gathering data to evaluate a request for an alternate version of itertools.izip() with a None fill-in feature like that for the built-in map() function: map(None, 'abc', '12345') # demonstrate map's None fill-in feature [('a', '1'), ('b', '2'), ('c', '3'), (None, '4'), (None, '5')] The motivation is to provide a means for looping over all data elements when the input lengths are unequal. The question of the day is whether that is both a common need and a good approach to real-world problems. The answer can likely be found in results from other programming languages and from surveying real-world Python code. Other languages --- I scanned the docs for Haskell, SML, and Perl6's yen operator and found that the norm for map() and zip() is to truncate to the shortest input or raise an exception for unequal input lengths. Ruby takes the opposite approach and fills-in nil values -- the reasoning behind the design choice is somewhat inscrutable: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-dev/18651 Real-world code --- I scanned the standard library, my own code, and a few third-party tools. I found no instances where map's fill-in feature was used. History of zip() PEP 201 (lock-step iteration) documents that a fill-in feature was contemplated and rejected for the zip() built-in introduced in Py2.0. In the years before and after, SourceForge logs show no requests for a fill-in feature. Request for more information My request for readers of comp.lang.python is to search your own code to see if map's None fill-in feature was ever used in real-world code (not toy examples). I'm curious about the context, how it was used, and what alternatives were rejected (i.e. did the fill-in feature improve the code). Likewise, I'm curious as to whether anyone has seen a zip-style fill-in feature employed to good effect in some other programming language. Parallel to SQL? If an iterator element's ordinal position were considered as a record key, then the proposal equates to a database-style full outer join operation (one which includes unmatched keys in the result) where record order is significant. Does an outer-join have anything to do with lock-step iteration? Is this a fundamental looping construct or just a theoretical wish-list item? Does Python need itertools.izip_longest() or would it just become a distracting piece of cruft? Raymond Hettinger FWIW, the OP's use case involved printing files in multiple columns: for f, g in itertools.izip_longest(file1, file2, fillin_value=''): print '%-20s\t|\t%-20s' % (f.rstrip(), g.rstrip()) The alternative was straightforward but less terse: while 1: f = file1.readline() g = file2.readline() if not f and not g: break print '%-20s\t|\t%-20s' % (f.rstrip(), g.rstrip()) -- http://mail.python.org/mailman/listinfo/python-list
Re: Real-world use cases for map's None fill-in feature?
Raymond Hettinger [EMAIL PROTECTED] wrote: ... Request for more information My request for readers of comp.lang.python is to search your own code to see if map's None fill-in feature was ever used in real-world code (not toy examples). I'm curious about the context, how it was used, and what alternatives were rejected (i.e. did the fill-in feature I had (years ago, version was 1.5.2) one real-world case of map(max, seq1, seq2). The sequences represented alternate scores for various features, using None to mean the score for this feature cannot be computed by the algorithm used to produce this sequence, and it was common to have one sequence longer (using a later-developed algorithm that computed more features). This use may have been an abuse of my observation that max(None, N) and max(N, None) were always N on the platform I was using at the time. I was relatively new at Python, and in retrospect I feel I might have been going for use all the new toys we've just gotten -- looping on feature index to compute the scores, and explicitly testing for None, might have been a better approach than building those lists (with seq1=map(scorer1, range(N)), btw) and then running map on them, anyway. At any rate, I later migrated to a lazily computed version, don't recall the exact details but it was something like (in today's Python): class LazyMergedList(object): def __init__(self, *fs): self.fs = *fs self.known= {} def __getitem__(self, n): try: return self.known[n] except KeyError: pass result = self.known[n] = max(f(n) for f in fs) return result when it turned out that in most cases the downstream code wasn't actually using all the features (just a small subset in each case), so computing all of them ahead of time was a waste of cycles. I don't recall ever relying on map's None-filling feature in other real-world cases, and, as I mentioned, even here the reliance was rather doubtful. OTOH, if I had easily been able to specify a different filler, I _would_ have been able to use it a couple of times. Alex -- http://mail.python.org/mailman/listinfo/python-list
is there any lib can split string in this way?
I want to split a string like this: 'abc def this is a test ok' into: ['abc', 'def', 'this is a test', 'ok'] is there any lib meet my need? thanks -- Best Regards, Leo Jay -- http://mail.python.org/mailman/listinfo/python-list
Re: Is 'everything' a refrence or isn't it?
Fredrik Lundh wrote: ...snip... afaik, the Python Language Reference never defines the word reference. It carefully defines words like object and value, though, and terms like call by object or call by object reference are perfectly understandable if you use the words as they are defined in the language reference. It (sec. 3.1, Objects, values and types) is not what I would call a good definition . About values it says only - that they are something that all objects have. - they can be mutable or immutable. It then has a few sentences about mutability, so after reading it you will know that, whatever a value is, it can be changed for some objects but not others. But what exactly it is that is being changed is still a mystery. Further down it talks about container objects containing references to other objects and of those being part of it's value. Part? What does it mean to contain? Can one determine from reading this, if an attribute value is part of the object's value? (I couldn't). On my list on Python Doc problems that need fixing, is defintion of object values and it has been on there for nearly a year. So I don't think referring people to the Language Reference is a good way to help them understand Python. Python badly needs a rewritten Language Reference. -- http://mail.python.org/mailman/listinfo/python-list
Re: Try Python update
[EMAIL PROTECTED] (Alex Martelli) writes: Meanwhile, other JS/DOM experts have told me that there's NO way to set cursor position within a textarea according to w3c standards. In this case, what your site does now may be the least bad approach, and that fact might be noted in the browsers subpage, together with a request for anybody who has other ideas to submit them, I guess. I've done that, and it should show up next time I push the code to the production server. Sorry for wasting your time, I'm still having trouble believing that the standards didn't bother to specify SOME way to perform such an elementary functionality. How many pages do you know of that actually want to do this? It may be fundamental, but it's atypical. I found three different ways to do it - none of them supported by Safari. Ironically, the browsers that do support any of those methods all keep the cursor at the end of the textarea when I add the new text, and so don't need them. Thanks, mike -- Mike Meyer [EMAIL PROTECTED] http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list
Re: building Python 2.4.2 on Mac OS X
On os x 10.4.3 to build a framework version unpack source dist python-2.4.2 ./configure --enable-framework make sudo makeframework install Please note that sudo make install won't work On 08 Jan, 2006, at 16:20, Vidar Gundersen wrote: are there any easy to understand instructions for building Python on Mac OS X Tiger? are there any prerequisites that i have missed? my ./configure make stops here: Python/mactoolboxglue.c:462: warning: return makes integer from pointer without a cast make: *** [Python/mactoolboxglue.o] Error 1 -- http://mail.python.org/mailman/listinfo/python-list ** Samuel M. Smith Ph.D. 2966 Fort Hill Road Eagle Mountain, Utah 84043 801-768-2768 voice 801-768-2769 fax ** The greatest source of failure and unhappiness in the world is giving up what we want most for what we want at the moment ** -- http://mail.python.org/mailman/listinfo/python-list
Why does Rpy/R-plot work under PythonWin, but not under commandline/IDLE?
Dear list, I am using rpy, a python module to control statistical package R from python. Running the following commands from rpy import * r.plot(0) will pass command 'plot' to R and run it. I notice that the R-plot will not refresh (a window is created but the figure is not drawn) until the next plot command is executed, * when I use python (2.3, 2.4) command line or IDLE * NOT when I use pythonwin ( provided with pywin32 package) Since rpy+R works under python+pythonwin, I assume that this is not a problem with rpy or R. Does anyone know why commandline/IDLE cause this problem, while PythonWin does not? I am interested to know what I can do in commandline (or in rpy) to fix this problem. Regards, Bo -- http://mail.python.org/mailman/listinfo/python-list
Re: Calling foreign functions from Python? ctypes?
=?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?= [EMAIL PROTECTED] writes: Paul Watson wrote: I need to call some Windows APIs. Is the only way to download ctypes or the win32 interfaces? That depends on the specific win32 interface you want to call. Typically, the answer is yes. Is there any plan to get ctypes batteries into the standard Python build? I don't have such a plan. To my knowledge, ctypes has never been contributed to Python, either, so its author apparently has no plan, either. As the author, I would be happy to see ctypes included with the standard Python build. Thomas -- http://mail.python.org/mailman/listinfo/python-list