Re: How to catch these kind of bugs in Python?

2006-08-19 Thread dave . brueck
asincero wrote: Is there anyway to catch the following type of bug in Python code: message = 'This is a message' if some_obscure_condition: nessage = 'Some obscure condition occured.' print message In the above example, message should be set to 'Some obscure condition occured.' if

Re: Writing backwards compatible code

2006-04-16 Thread Dave Brueck
Steven D'Aprano wrote: I came across an interesting (as in the Chinese curse) problem today. I had to modify a piece of code using generator expressions written with Python 2.4 in mind to run under version 2.3, but I wanted the code to continue to use the generator expression if possible.

Re: python speed

2005-11-30 Thread Dave Brueck
Steven Bethard wrote: David Rasmussen wrote: Harald Armin Massa wrote: Dr. Armin Rigo has some mathematical proof, that High Level Languages like esp. Python are able to be faster than low level code like Fortran, C or assembly. Faster than assembly? LOL... :) I think the claim goes

Re: Threading

2005-11-02 Thread Dave Brueck
Tuvas wrote: I am trying to write a thread that will execute a function every 2 seconds until the program is close, in which case it will stop. I can write the program easy enough to execute the command every 2 seconds, the problem comes when I try to close the program. It won't close the

Re: System tray Icon

2005-10-23 Thread Dave Brueck
Mike Pippin wrote: How would I have an app run with just a system tray Icon??? any help would be greatly appreciated. I have no clue where to start. Choose a GUI toolkit, e.g. wxPython. -- http://mail.python.org/mailman/listinfo/python-list

Re: Extention Woes

2005-10-19 Thread Dave Brueck
Tuvas wrote: I am in the process of writing an extention module, and am coming up with lots of problems. This isn't a direct answer to your question, but what sort of extension is it? Do you need to actually write a Python extension? I ask because I've all but stopped writing Python extension

Re: destroy your self????

2005-10-19 Thread Dave Brueck
KraftDiner wrote: if I create an object like... obj = None ... obj = anObject() can obj set itself to none in some method of the class? No - Python doesn't work that way. What are you trying to accomplish? There's probably a way to do what you need to do, but this isn't it. -Dave --

Re: destroy your self????

2005-10-19 Thread Dave Brueck
KraftDiner wrote: Well I guess what I'm trying to achive is the invalidate the instance of the object. I have been using None to denote an invalide or uninitialized instance of an object. There is a degenerate case in my code where a polygon has less than 3 points and I want to class to

Re: Well written open source Python apps

2005-10-17 Thread dave . brueck
Steve M wrote: Here is an article discussing the coding style of BitTorrent. http://www.onlamp.com/pub/a/python/2003/7/17/pythonnews.html Maybe that code is worth looking at. [didn't read this thread or that article until I saw the summary in Dr. Dobb's Python-URL] FWIW, the BitTorrent code

Re: Why do Pythoneers reinvent the wheel?

2005-09-09 Thread Dave Brueck
Stefano Masini wrote: I wonder how many people (including myself) have implemented their own versions of such modules, at least once in their pythonic life. I indeed have my own odict (even same name! :). My own pathutils (different name, but same stuff). My own validate... and so forth.

Re: Pervasive Database Connection

2005-09-06 Thread Dave Brueck
Alex Le Dain wrote: What is the best way to access a Pervasive database on another machine? Hi Alex, You can use ODBC / ADO to access Pervasive DBs. I found this page helpful: http://www.mayukhbose.com/python/ado/index.php -Dave -- http://mail.python.org/mailman/listinfo/python-list

Re: Decline and fall of scripting languages ?

2005-08-08 Thread Dave Brueck
Paul Rubin wrote: Ruby just doesn't interest me that much though (maybe I'm missing something). I don't think you are. My impression is that if you've never used Python or Ruby, you'll generally end up liking whichever of the two you really discover first (since the common case is that you're

Re: Yet Another Python Web Programming Question

2005-07-09 Thread Dave Brueck
Daniel Bickett wrote: He would read the documentation of Nevow, Zope, and Quixote, and would find none of them to his liking because: * They had a learning curve, and he was not at all interested, being eager to fulfill his new idea for the web app. It was his opinion that web programming

Re: Lisp development with macros faster than Python development?..

2005-07-05 Thread Dave Brueck
[EMAIL PROTECTED] wrote: I've been reading the beloved Paul Graham's Hackers and Painters. He claims he developed a web app at light speed using Lisp and lots of macros. It got me curious if Lisp is inherently faster to develop complex apps in. It would seem if you could create your own

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-24 Thread Dave Brueck
D H wrote: Peter Hansen wrote: D H wrote: Peter Hansen wrote: Bo Peng wrote: Actually that's just one possible answer. Whether it's _the_ answer is obviously again a matter of opinion, and as usual we differ. Quit being such an idiot and refuting everything I say. The answer is simply no,

Re: Socket Speed

2005-06-05 Thread Dave Brueck
[EMAIL PROTECTED] wrote: Hi All I'm busy writing a python p2p program and would like some advice. I'm pushing about 300k/s and would like to know if there are any python tricks I could pull to speed things up. I'm thinking about unrolling some of the loops and recuding calls to my custom

Re: working with pointers

2005-05-31 Thread Dave Brueck
Michael wrote: sorry, I'm used to working in c++ :-p if i do a=2 b=a b=0 then a is still 2!? so when do = mean a reference to the same object Always. and when does it mean make a copy of the object?? Never. -Dave -- http://mail.python.org/mailman/listinfo/python-list

Re: Is Python suitable for a huge, enterprise size app?

2005-05-21 Thread Dave Brueck
Paul Rubin wrote: Dave Brueck [EMAIL PROTECTED] writes: What do you use for HTTPS? m2crypto (plus some patches to make asynchronous SSL do what we needed). That seems to be a nice piece of code, but it's still at version 0.13; Version numbers are fairly relative, though. In another

Re: Is Python suitable for a huge, enterprise size app?

2005-05-20 Thread Dave Brueck
Paul Rubin wrote: Dave Brueck [EMAIL PROTECTED] writes: One thing from your experience that did resonate with me is that, except for ftplib and occasionally urllib (for basic, one-shot GETs), we don't use any of the standard library's protocol modules - partly because we had to implement our

Re: Is Python suitable for a huge, enterprise size app?

2005-05-19 Thread Dave Brueck
Paul Rubin wrote: Kay Schluehr [EMAIL PROTECTED] writes: To answer Your initial question: there is probably no technical reason against Python as a language or the CPython runtime. Both are very stable and mature. I'd like to agree with this but I just can't. Python is a great language for

Re: Is Python suitable for a huge, enterprise size app?

2005-05-18 Thread Dave Brueck
john67 wrote: The company I work for is about to embark on developing a commercial application that will cost us tens-of-millions to develop. [snip] Right now it looks like Java is the language of choice that the app will be developed in. However, I have been looking and reading a lot about

Re: Is Python suitable for a huge, enterprise size app?

2005-05-18 Thread Dave Brueck
EHP wrote: Python has good database support, it works well on a wide range of platforms, and it's great at tying together different processes, machines, etc. - for example, it's fairly easy to get Python to access C code, dynamic libraries, system APIs, and external programs. It's easier to test

Re: Is Python suitable for a huge, enterprise size app?

2005-05-18 Thread Dave Brueck
George Sakkis wrote: Personally, although I find nothing comes close to the clarity and flexibility that python offers, in this case I would go with java, if for nothing else, to be on the safe side. Think about it: if the project fails (and that's quite likely for huge projects, not dark

Re: Windows distribution suggestions?

2005-05-17 Thread dave . brueck
One tip: make sure your three top-level scripts are as empty as possible: just import some other module and call a function. All your active code is then in some library.zip shared between the three, and you need never change alice.exe, bob.exe, and carol.exe I think I understand what you're

Re: Reading image dimensions with PIL

2005-05-17 Thread Dave Brueck
Will McGugan wrote: I'm writing an app that downloads images. It rejects images that are under a certain size - whithout downloading them completely. I've implemented this using PIL, by downloading the first K and trying to create a PIL image with it. PIL raises an exception because the

Re: Python forum

2005-05-17 Thread Dave Brueck
Grant Edwards wrote: On 2005-05-17, Jonas Melian [EMAIL PROTECTED] wrote: I'm going to say a suggestion, why don't you create a forum like the one of Ruby (http://www.rubyforums.com/)? for the novices this is a great help, better than a mail list [snip] But I think that a forum is great for the

Re: speeding up Python

2005-05-17 Thread Dave Brueck
Luis P. Mendes wrote: I have a 1000 line python script that takes many hours to finish. It is running with six inside 'for' loops. Hi Luis, Before going too much into optimizing your current code, you might want to take a step back and see if another approach to your problem might work

Re: Structuring larger applications - ideas

2005-05-16 Thread Dave Brueck
[EMAIL PROTECTED] wrote: I'm busy with a large application and feel it would eas my work if I can specify dependencies on the granularity of packages, rather than modules and classes. Eg: - By convention I do the one class per file thing. SO in python this means one class per module -

Re: plug-ins

2005-05-07 Thread Dave Brueck
Eric Nieuwland wrote: The app I'm working on keeps getting new transforms and I'm tired of adding them by hand. So here it goes: Can anyone provide me with clues/examples/references on how to create a plug-in framework? The biggest task is defining the interface between your app and the

Re: Dr. Dobb's Python-URL! - weekly Python news and links (Apr 11)

2005-04-14 Thread Dave Brueck
Roel Schroeven wrote: Simon Brunning wrote: ... Not that it really matters, but does anybody know why the weekly Python news always arrives twice? Does it only happen to me, or does it happen to others too? It's not that it irritates me or anything, I'm just being curious. I just thought it was

Re: Can't Stop Process On Windows

2005-04-12 Thread Dave Brueck
Dan wrote: I have a python script running under Windows XP that I need to terminate from the keyboard. A control-c works fine under Linux, but not under Windows. I'm pretty sure that the culprit is 'select' that I'm using to multiplex socket i/o, which seems to be blocking the keyboard

Re: Python 2.4 killing commercial Windows Python development ?

2005-04-12 Thread Dave Brueck
Terry Reedy wrote: I guess I don't understand some people's determination to not have users install fully useable Python on their Windows machines. [snip] To put it another way, needing a Python interpreter to run .py files is no different from, for instance, needing a movie player to run .mpg

Re: Python 2.4 killing commercial Windows Python development ?

2005-04-12 Thread Dave Brueck
Thomas Heller wrote: Dave Brueck [EMAIL PROTECTED] writes: Terry Reedy wrote: If there is something about the default install of Python on Windows that makes it less desireable or less easy than other platforms, then maybe that can be fixed. To make installation easier, maybe someone could write

Re: Are circular dependencies possible in Python?

2005-04-09 Thread Dave Brueck
Tim Tyler wrote: Like C, Python seems to insist I declare functions before calling them - rather than, say, scanning to the end of the current script when it can't immediately find what function I'm referring to. Yes and no. Yes, they have to exist before you can use them (that only makes sense),

Re: Sockets

2005-04-08 Thread Dave Brueck
Dan wrote: On Thu, 7 Apr 2005 21:52:11 -0500, [EMAIL PROTECTED] wrote: Python strings always carry their length, and can have embedded NULs. s.write(\0\1\2\3) should write 4 bytes to the socket 's'. I'm taking binary data from a database, so it's not really a Python string. Is there an easy

Re: Distributing closed source modules

2005-03-29 Thread Dave Brueck
Fuzzyman wrote: Dave Brueck wrote: By futile I meant that, if the code ends up running on a user's machine, then a sufficiently motivated person could crack it wide open, regardless of implementation language - the only way to truly protect the code is to never let it out of your hands (i.e. it's

Re: Distributing closed source modules

2005-03-25 Thread Dave Brueck
Fuzzyman wrote: Dave Brueck wrote: It's certainly something lot's of people are interested in. I guess it depends who your audience is. If ytour code isn't for *mass* distribution - the chances of people putting a lot of effort into breaking it are greatly reduced. I don't htink it's necessarily

Re: Distributing closed source modules

2005-03-24 Thread Dave Brueck
Jiri Barton wrote: I'd like to be able to distribute some python modules of my system (plugins) without the source. So far, I have done this by including only the *.pyc files. However, I have recently found they are platform dependent and python version dependent. This approach has been very

Re: Apparently, I don't understand threading

2005-03-13 Thread Dave Brueck
[EMAIL PROTECTED] wrote: The following script does not behave as expected. I wanted to terminate the 'mythread' thread after 5 seconds. What I see is the threading.Thread call blocking until the 15 second sleep is done. Suggestions? [snip] foo = FooClass() mythread =

Re: intigrate the PyGame module with my Python

2005-03-07 Thread Dave Brueck
Warren Postma wrote: 1. Downloaded the windows binary for python 1.5.2 from python.org. Pygame uses Python 1.5.2 still!? :-) Oi. Nah, must have been a typo, as www.pygame.org lists Windows installers for Python 2.2, 2.3, and 2.4: http://www.pygame.org/download.shtml -Dave --

Re: Dealing with config files what's the options

2005-02-25 Thread Dave Brueck
Jorgen Grahn wrote: On Tue, 22 Feb 2005 20:38:28 -0500, Tom Willis [EMAIL PROTECTED] wrote: How are the expert pythoneers dealing with config files? ... Any ideas? How about writing them in Python? Depending on who will be editing the config files, this can be a great approach. At the simplest

Re: Dealing with config files what's the options

2005-02-25 Thread Dave Brueck
Tom Willis wrote: On Fri, 25 Feb 2005 15:02:04 -0700, Dave Brueck How about writing them in Python? Depending on who will be editing the config files, this can be a great approach. [snip] I actually thought of this, and I was kind of on the fence due to the intended audience. I don't think it's

Re: urllib2 meta-refresh

2005-02-25 Thread Dave Brueck
Artificial Life wrote: urllib2 does not seem to be able to handle META-REFRESH in an html document. I just get back the html to the page that is supposed to forward me to the intended page. Right - urllib2 is for working with protocols (like HTTP) to transfer data, whereas META-REFRESH is an

Re: kill a process in XP

2005-02-23 Thread Dave Brueck
Tor Erik Sønvisen wrote: From my Python-program I spawn a new process. When using P_NOWAIT spawnl returns the pid but in windows it returns a process handle. Later I want to kill this process. How can I do this when I only have the process handle? Try ctypes - if it's really a Windows handle,

Re: Python and Ajax technology collaboration

2005-02-23 Thread Dave Brueck
John Willems wrote: Interesting GUI developments, it seems. Anyone developed a Ajax application using Python? Very curious thx (Ajax stands for: XHTML and CSS; dynamic display and interaction using the Document Object Model; data interchange and manipulation using XML and XSLT; asynchronous

ZODB performance (was Re: low-end persistence strategies?)

2005-02-16 Thread Dave Brueck
Chris Cioffi wrote: I'd like to second this one...ZODB is *extremely* easy to use. I use it in projects with anything from a couple dozen simple objects all the way up to a moderately complex system with several hundred thousand stored custom objects. (I would use it for very complex systems as

Re: Kill GIL

2005-02-14 Thread Dave Brueck
Donn Cave wrote: Quoth Dave Brueck [EMAIL PROTECTED]: ... | Another related benefit is that a lot of application state is implicitly and | automatically managed by your local variables when the task is running in a | separate thread, whereas other approaches often end up forcing you to think

Re: Kill GIL

2005-02-13 Thread Dave Brueck
Mike Meyer wrote: [EMAIL PROTECTED] (Aahz) writes: In article [EMAIL PROTECTED], Mike Meyer [EMAIL PROTECTED] wrote: Here here. I find that threading typically introduces worse problems than it purports to solve. Threads are also good for handling blocking I/O. Actually, this is one of the

Re: For American numbers

2005-02-13 Thread Dave Brueck
Peter Hansen wrote: Martin v. Löwis wrote: Peter Hansen wrote: For the rest of the computer world, unless I've missed a changing of the guard or something, kilo is 1024 and mega is 1024*1024 and so forth... In case this isn't clear yet: you have missed a changing of the guard or something. kibi is

Re: OT: why are LAMP sites slow?

2005-02-04 Thread Dave Brueck
Steve Holden wrote: Paul Rubin wrote: Skip Montanaro [EMAIL PROTECTED] writes: It's more than a bit unfair to compare Wikipedia with Ebay or Google. Even though Wikipedia may be running on high-performance hardware, it's unlikely that they have anything like the underlying network structure

Re: OT: why are LAMP sites slow?

2005-02-04 Thread Dave Brueck
Fredrik Lundh wrote: Tim Daneliuk wrote: THis is why, IMHO, things like SOAP a laughable - RPC is a poor foundation for reliable, durable, and high-performance TP. It might be fine for sending an order or invoice now and then, but sustained through- put of the sort I think of as high performance

Re: Possibly OT: Controlling winamp with Python

2005-02-04 Thread Dave Brueck
Brent W. Hughes wrote: I'm running Windows XP and I'm using winamp to listen to internet radio stations. Occasionally, an annoying commercial will come on. I would like to write a Python program that, when run, will, in essence, push on winamp's mute button. Then, after say 20 seconds, it

Re: Where is WSAEnumNetworkEvents???

2005-02-03 Thread Dave Brueck
[EMAIL PROTECTED] wrote: I was trying to write an asyncronous TCP server for win32 using WSAEventSelect (which lives if win32file). Such events require WaitForMultipleObjects (which lives if win32event) and WSAEnumNetworkEvents WHICH IS NOT EXPOSED. This makes WSAEventSelect useless. Does somebody

Re: Best python postgres module?

2005-01-28 Thread Dave Brueck
Roland Heiber wrote: i recently migrated from mysql to postgresql and did use severel python postgres-modules. All do what they are designed for, so which one would you use? psycopg, pygresql, pypgsql? psycopg seems to be the best solution for heavy traffic/multiple connections i have no

Re: how to call python code from C#

2005-01-24 Thread Dave Brueck
Peter Hansen wrote: paritosh mahana wrote: How can I call python code from my C# code. [snip] You could use ctypes or the pywin32 package to provide your Python code with an ActiveX interface. Then you could just use it via COM, like any other COM object. Lots of references available via Google

Re: Determining if a client PC has an Internet connection

2005-01-23 Thread Dave Brueck
torment wrote: [snip] Have you tried just parsing the output from the command ipconfig? It's pretty obvious from the output that might give you if a connection is availible. It's tempting to use ipconfig's output, but the info it gives you is unreliable - you can incorrectly infer the presence of

Re: Python evolution: Unease

2005-01-04 Thread Dave Brueck
Istvan Albert wrote: Doug Holton wrote: application is so important that I expect Python 3000 will have optional type declarations integrated into the argument list. I think that *optional* part of the optional type declaration is a myth. It may be optional in the sense that the language will

Re: Python evolution: Unease

2005-01-04 Thread Dave Brueck
Roman Suzi wrote: On Tue, 4 Jan 2005, Dave Brueck wrote: It may be optional in the sense that the language will accept missing declarations but as soon as the feature is available it will become mandatory to use it (peer pressure, workplace practices). What about generic programming coming

Re: Python evolution: Unease

2005-01-04 Thread Dave Brueck
Roman Suzi wrote: The term generic programming is too... er... generic. :) Nope. It is not generic. It has it's definition made by the co-author of STL - A.Stepanov. And the Boost C++ library (many of us know it as Boost Python) standardise on the approach, AFAIK. Ok, too broad then; Python