Re: Tricky Dictionary Question from newbie

2005-07-12 Thread James Carroll
Notice the dictionary is only changed if the key was missing. a = {} a.setdefault(a, 1) '1' a.setdefault(a, 2) '1' a.setdefault(b, 3) '3' a {'a': '1', 'b': '3'} a.setdefault(a, 5) '1' a {'a': '1', 'b': '3'} -Jim On 7/11/05, Peter Hansen [EMAIL PROTECTED] wrote: Ric Da Force wrote: How

Re: Tricky Dictionary Question from newbie

2005-07-12 Thread James Carroll
next guess at a better name for setdefault would be: value = container.GetOrAddDefault(key=a, default=[]) value.append(listvalue) but that's kind of confusing too, but it better describes what is happening. -Jim On 7/12/05, Peter Hansen [EMAIL PROTECTED] wrote: (Fixed top-posting) James

Re: cursor positioning

2005-07-11 Thread James Carroll
I haven't tried this myself, but I think the secret to displaying a continuously updating %done on the command line is to print file 100, 1% done then send exactly 7 backspaces to the terminal, then print 2% done... so the backspaces will write over the previous text. Backspace is a \x08

Re: FlashMX and Py2exe doesn't fly...

2005-06-27 Thread James Carroll
They did it with Gush: (I think) http://2entwine.com/ It's a py program that embeds Flash very nice. -Jim On 27 Jun 2005 15:11:11 -0700, Grops [EMAIL PROTECTED] wrote: Flash and Python could be a VERY powerful pair of tools for building quick apps, Yet I don't see much on the web

Swig wrapping C++ Polymorphism

2005-06-23 Thread James Carroll
Hi, I asked this on the SWIG mailing list, but it's pretty dead over there... I'm trying to get Python to pass a subclass of a C++ object to another C++ object... I have three C++ classes, TiledImageSource ZoomifyReaderWx which ISA TiledImageSource TiffWriter which has a method which takes a

Re: User interfaces in console (dialog like)

2005-06-23 Thread James Carroll
Wow, I was just reminiscing about my old TurboVision days... I second the recommendation. On 6/23/05, Jeremy Sanders [EMAIL PROTECTED] wrote: Negroup wrote: Do you guys know an alternative that fits my needings without moving from Python? Turbo Vision in dos used to be really good.

Re: Extensions on Linux: import without underscore?

2005-06-20 Thread James Carroll
Swig actually was generating a bright.py file, but scons was leaving it in the source directory instead of putting it next to my SharedLibrary(). Once I moved the bright.py next to the _bright.so, it all worked with just import bright. Thanks everyone. My next trick is to try the same thing

Extensions on Linux: import without underscore?

2005-06-18 Thread James Carroll
Hi, I'm creating an extension called _bright.so on linux. I can import it with import _bright, but how can I import bright and get the package? On windows, I've been able to import bright instead of import _bright, but on Linux it seems to need the underscore. I'm tempted to create a bright.py

Re: Extensions on Linux: import without underscore?

2005-06-18 Thread James Carroll
Thanks Robert. Call it bright.so . If I rename it bright.so, then I get the error: ImportError: dynamic module does not define init function (initbright) I'm using swig with the module declaration %module bright I've looked at some other source, and it looks like there are some good

Re: dynamic

2005-06-16 Thread James Carroll
Oh, I see. Yeah, having the code look like you're instantiating one class, but really getting a different one is really horrible. Sorry I didn't catch on to the subtlety. I'm always complaining about code that looks like it does one thing, but really does another. -Jim On 15 Jun 2005

Re: Tiff Image Reader/writer

2005-06-16 Thread James Carroll
I did a test with wxPython 2.6.1 on Windows. I created a G4 TIFF image that was 4400 x 3599 big, and the following code took under a half second. import wx import time def readImage(filename): img = wx.Image(filename) w = img.GetWidth() h = img.GetHeight() value = img.GetGreen(w

Re: dynamic

2005-06-15 Thread James Carroll
Returning instances of some other class is not so horrible. They're called FactoryMethods usually. An example is when you have a polymorphic tree of image file reader objects, and you open an image file, it might return a JpegReader which ISA ImageReader or a TIFFReader which also ISA

Re: Tiff Image Reader/writer

2005-06-15 Thread James Carroll
What do you mean by decode the pixels? If there's some image processing that needs to be done, or if you want to view, brighten, or print or something, then there are ways of doing it that will be as fast as can be. If stepping through the pixels to do your own math is what you want, then maybe

Re: Tiff Image Reader/writer

2005-06-14 Thread James Carroll
Hmm... that's unfortunate. What platform are you on? If Windows, then I believe that PIL is statically linked against LibTIFF and that particular libtiff wasn't compiled with certain options (CCITT formats or something.) (in 1999 that was true, I found a post from Fred here:

Re: Tiff Image Reader/writer

2005-06-13 Thread James Carroll
What sort of things do you want to do with the TIFFs? How heavy-weight or light-weight are you interested in? For heavy-weight there are: - wxPython will do a bunch of tiff reading, and some image processing http://www.wxpython.org - GDAL (quoting Khalid Zuberi:) GDAL supports GeoTIFF and

Re: cgi script runs under Opera, but not firefox

2005-06-11 Thread James Carroll
Try View Source under Firefox, you should see everything that you're printing from your CGI on the server. The server side CGI will do the same thing no matter what browser is requesting the page. Next, take that source and paste into into some app that will look for problems like tags that

Re: help

2005-06-09 Thread James Carroll
When i try to open IDLE(python GUI) it says that i have a socket error: conection refused what do i do to fix this if you're on linux, try making sure that localhost (the lo interface) is up and running if you do an ifconfig you should see one paragraph for the lo interface, and if you do an

Re: PySol not working on WinXP, SP2

2005-06-01 Thread James Carroll
You might try finding the source to pysol, and you might notice that you have a bunch of *.py files and for each of those, a corresponding .pyc file. If you delete all the pyc files, then they'll get re-created from the .py files, and you might be all set. -Jim On 6/1/05, Ivan Van Laningham

Where do I find the dispatch name?

2005-05-25 Thread James Carroll
I just ran makepy to create a wrapper for my com object, and it generated the wrapper with the CLSID.py under site-packages/win32com/gen_py/ Now, I'm trying to figure out how to invoke it. How do I figure out what string to give Dispatch? For instance: xl =

Re: Where do I find the dispatch name?

2005-05-25 Thread James Carroll
Answering self I looked through all the IIDs in: PythonWin, Tools, COM Object Browser, RegisteredCategories, Automation Objects. After looking through all the IIDs I saw one that looked like it might work... and it did. -Jim On 5/25/05, James Carroll [EMAIL PROTECTED] wrote: I just ran

using a com automation object (how do I avoid crash?)

2005-05-25 Thread James Carroll
I'm trying to call functions on an automation object, and I've run makepy to generate a wrapper, and 99% of the calls I make on the wrapper work great. my question is: Is my [''] * 10 as close as I can come to a variant array of pre-allocated empty strings? I'm trying to call a function called

Re: Running a python program during idle time only

2005-05-23 Thread James Carroll
I think you can keep your sleep commands in your program to keep it from hogging the cpu even when you are running it as nice. You know, even more important than cpu load (since your indexer is accessing the hard drive, is hard drive access..) You can monitor the bytes / second going to the

Fwd: Running a python program during idle time only

2005-05-23 Thread James Carroll
I think you can keep your sleep commands in your program to keep it from hogging the cpu even when you are running it as nice. You know, even more important than cpu load (since your indexer is accessing the hard drive, is hard drive access..) You can monitor the bytes / second going to the

Re: Running a python program during idle time only

2005-05-21 Thread James Carroll
There's probably a way to tell how long the user has been idle, but here's how you can check the CPU load to see if it's elevated... (of course your program might elevate it too.) On linux, you can read from /proc/loadavg Here's a fun thing to try on windows... make sure you have the win32all

Re: speeding up Python script

2005-05-18 Thread James Carroll
It looks like your algorithm really does iterate over all values for six variables and do lots of math.. then you can't do any better than implementing the inner loop in C. It does look like you have some functions that are being called that are also in python, and it would be interesting to see

Re: HELP Printing with wxPython

2005-05-12 Thread James Carroll
the wxPython mailing list people know about it, and they'll have a work-around or a fix (or show you what you should be doing) in no time. -Jim On 5/11/05, Mario [EMAIL PROTECTED] wrote: James Carroll [EMAIL PROTECTED] wrote: I especially like the HtmlEasyPrinting write-up here: http

Re: Python Documentation (vs PHP stuff)

2005-05-12 Thread James Carroll
Conclusion 1: if PHP is anything as awful as the manual, it is not for me. the whole idea that turning the manual into a wiki or a forum will solve all problems is extremely naive. Wha? I haven't done PHP for a couple of years, but when I really needed documentation, the PHP docs were

Re: HELP Printing with wxPython

2005-05-11 Thread James Carroll
Hi Mario, Something like SendPrinter(some text\n)? If you are doing this just for yourself, and you know you have a printer that will really print just the plain text when you send it plain text (like a dot matrix printer from the early 90s) then you can probably open the printer device and

Fwd: Interactive shell for demonstration purposes

2005-05-11 Thread James Carroll
-- Forwarded message -- From: James Carroll [EMAIL PROTECTED] Date: May 11, 2005 10:43 AM Subject: Re: Interactive shell for demonstration purposes To: Brian Quinlan [EMAIL PROTECTED] I would personally try looking at the PyCrust.py that's included with wxPython. It has

Re: Resize an Image without PIL

2005-05-09 Thread James Carroll
Or if you're using wxPython, wx.Image can load, rescale and save. There's also a Python wrapper for imageMagick, which will do just about anything to medium-small files. One way or another you'll need to incorporate (depend on) something that can decode the various image file formats that you

Re: Python Challenge ahead [NEW] for riddle lovers

2005-05-05 Thread James Carroll
Och! Thanks for the hint! I actually guessed the answer of who to phone earlier in the day, but didn't have the capitolization correct... Damn! Great riddles! -Jim On 5/5/05, Martijn Pieters [EMAIL PROTECTED] wrote: [SNIP me whining then cheering about level 13] Dan Bishop wrote: You

Re: Why Python does *SLICING* the way it does??

2005-04-20 Thread James Carroll
If you have five elements, numbered 0,1,2,3,4 and you ask for the elements starting with the first one, and so on for the length you would have [0:length]. So [0:5] gives you elemets 0,1,2,3,4. Think of the weirdess if you had to ask for [0:length-1] to get length elements... One based 1...

Re: (Python newbie) Using XP-SP2/MSVC6: No Python24_d.lib, winzip barfs on Python-2.4.1.tar, cannot download bzip2

2005-04-18 Thread James Carroll
Hi Bill, Python 2.4 requires VC7.1 I just ran into this recently. Once I installed VC7.1, I could easily compile the Python source to create a debug lib. Winzip should be able to read the python source tarball... There is one trick though. Once you download it, it might get renamed to

Re: py2exe - create one EXE

2005-04-15 Thread James Carroll
I like that you can automatically invoke NSIS and create an installer, but I thought the question was how can all of the libraries be in a single runnable program executable (not a program that installs, but the program that you wrote.) I don't think you can do this, because (unless you have your