Re: PIL's ImageFile Parser and PNG's

2008-11-12 Thread Silfheed
On Nov 12, 5:28 pm, Silfheed <[EMAIL PROTECTED]> wrote: > Heyas > > So I've been messing around with the PIL and PNG's and came across a > little problem with PNG's. > > So just to clarify, I'm running with the standard ubuntu 8.04 python- > imaging package that installs zlib and all the other good

Re: Official definition of call-by-value (Re: Finding the instance reference...)

2008-11-12 Thread George Sakkis
On Nov 12, 4:05 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > greg wrote: > >> It's not only misleading, it's also a seriously flawed reading of the > >> original text - the Algol 60 report explicitly talks about assignment > >> of *values*. > > > Do you agree that an expression in Python has a v

Re: duck-type-checking?

2008-11-12 Thread Steven D'Aprano
On Wed, 12 Nov 2008 08:06:31 -0700, Joe Strout wrote: > Let me preface this by saying that I think I "get" the concept of duck- > typing. > > However, I still want to sprinkle my code with assertions that, for > example, my parameters are what they're supposed to be -- too often I > mistakenly pa

memory mapped tar file contents

2008-11-12 Thread Chris Brooks
Hi, I would like to read directly from a tar file into memory so I can manipulate a file (quickly) and write its changes out to another file. I thought I could do something like: #!/usr/bin/env python import tarfile import mmap fil = tarfile.open( "out.tar.gz" , "r:gz" ) tarinf = fil.next() m

Re: memory mapped tar file contents

2008-11-12 Thread Jean-Paul Calderone
On Wed, 12 Nov 2008 18:51:38 -0800 (PST), Chris Brooks <[EMAIL PROTECTED]> wrote: Hi, I would like to read directly from a tar file into memory so I can manipulate a file (quickly) and write its changes out to another file. I thought I could do something like: If you mmap a tar file, then y

Re: concurrency program design stackless python tasklet or python thread?

2008-11-12 Thread davy zhang
thank you very much for the advices! I asked myself many times, why not just use thread:D After some research I found thread has some fatal defects 1. thread number is limited by os, that means the system don't want you start many threads at the same time 2. thread pool is another approach for c

what should we use instead of the 'new' module?

2008-11-12 Thread Flavio
How is this code going to look like in Python 3.0? (it's deprecated according to http://docs.python.org/library/new.html#module-new, but it does not tell what to use instead) method = new.instancemethod(raw_func, None, cls) setattr(cls, name, method) Can we write code in python2.5/2.6 that will

Re: what should we use instead of the 'new' module?

2008-11-12 Thread Robert Kern
Flavio wrote: How is this code going to look like in Python 3.0? (it's deprecated according to http://docs.python.org/library/new.html#module-new, but it does not tell what to use instead) method = new.instancemethod(raw_func, None, cls) setattr(cls, name, method) Use the type objects in the

potential bug in UnixMailbox method of Python

2008-11-12 Thread Sirshendu Rakshit
Hi,I am using UnixMailbox to parse an mbox file. This mbox file starts with the following lines.From [EMAIL PROTECTED] May 18 01:43:12 2004>From [EMAIL PROTECTED] May 18 01:43:12 2004ReturnPath: XOriginalTo: [EMAIL PROTECTED]: [EMAIL PROTECTED] what I am seeing is that the '>From [EMAIL PROTECTE

Re: what should we use instead of the 'new' module?

2008-11-12 Thread flrump
Robert, Appreciate your response. However Guido says here that types was never intended to be used like that: http://bugs.python.org/msg58023 quote: "The types module was only ever intended for type checking, not for creating new instances. The correct solution will be to use whatever we end u

Re: what should we use instead of the 'new' module?

2008-11-12 Thread Benjamin
On Nov 12, 9:54 pm, [EMAIL PROTECTED] wrote: > Robert, > > Appreciate your response. > > However Guido says here that types was never intended to be used like > that: > > http://bugs.python.org/msg58023 > > quote: "The types module was only ever intended for type > checking, not for creating new in

Re: what should we use instead of the 'new' module?

2008-11-12 Thread Robert Kern
[EMAIL PROTECTED] wrote: Robert, Appreciate your response. However Guido says here that types was never intended to be used like that: http://bugs.python.org/msg58023 quote: "The types module was only ever intended for type checking, not for creating new instances. The correct solution will

Re: Finding the instance reference of an object

2008-11-12 Thread Craig Allen
> arguably even older than that to Lisp. > Firstly, thanks to those that have responded to my part in this debate, I have found it very informative and interesting as I have the entire thread. However, with regard to comments that I led myself astray, I want to reiterate the one thing I find det

Re: need to suspend/resume a child thread

2008-11-12 Thread Miki
Hello, > A child thread has a long-time executions, how to suspend it and resume > back the orignial place ? I don't think you can do it using Python's thread API. You can either use a platform specific API (such as pywin32) or make the thread "cooperative" and wait on a condition/semaphore in som

Re: Single-instance daemons

2008-11-12 Thread Jeffrey Barish
Jeff McNeil wrote: > Sure, start the daemon as root, write the appropriate files, and then > drop permissions using os.setegid and then os.seteuid. You can chown > the file before priv. drop to your target user so that it can be > removed when your exit handlers run.  Alternatively, you can reclai

Easy caching

2008-11-12 Thread jalanb3
Evening all, And thank you for your valuable reading skills. The following pattern turned up in coding tonight. It works, but I'm suspicious, it just seems too easy. So any comments or constructive criticisms welcome ? *** Start doctest format *** >>> class Cacher: ... def

Re: Single-instance daemons

2008-11-12 Thread Jeffrey Barish
Cameron Simpson wrote: > Or, more simply, get root to make an empty pid file once and chown it to > the daemon user. Then the daemon can rewrite the file as needed. You need > to move to truncating the file instead of removing it on daemon shutdown, > but that is trivial. And no mucking with privi

Re: cannot pickle object returned by urllib2.urlopen()

2008-11-12 Thread greg
On Wed, 12 Nov 2008 11:00:26 +0800, scsoce wrote: got a exception: "a class that defines __slots__ without defining __getstate__ cannot be pickled " why? Because in the absence of any other information, the default way of pickling an object is to save the contents of its __dict__. But an obje

Re: Printing a "status " line from a python script

2008-11-12 Thread Alex VanderWoude
Chris Seymour wrote: I am working on a python script for my colleague that will walk a directory and search in the different files for a specific string. These pieces I am able to do. What my colleague wants is that when she runs the script the filename is replaced by the current file that is be

Re: memory mapped tar file contents

2008-11-12 Thread Chris Brooks
Jean-Paul Calderone wrote: > > If you mmap a tar file, then you'll get a bunch of tar formatted stuff. > If > you mmap a gzipped tar file, then you'll get a bunch of gzipped stuff. > Are > you sure that's what you want? From your code snippet, it looks more like > you want the uncompressed f

Re: duck-type-checking?

2008-11-12 Thread greg
Joe Strout wrote: This is not hypothetical -- just last week I had a hard-to-track-down abend that ultimately turned out to be an NLTK.Tree object stored someplace that I expected to only contain strings. I found it by littering my code with assertions of the form isinstance(foo,basestrin

Re: duck-type-checking?

2008-11-12 Thread greg
Joe Strout wrote: I'd rather risk something that breaks the code in an obvious way during development, than risk something that breaks it in a subtle way and is more likely to be discovered by the end-user. Seems to me that putting in these kinds of assertions isn't going to make much diff

Re: memory mapped tar file contents

2008-11-12 Thread Aaron Brady
On Nov 12, 8:51 pm, Chris Brooks <[EMAIL PROTECTED]> wrote: > Hi, > > I would like to read directly from a tar file into memory so I can > manipulate a file (quickly) and write its changes out to another file.  I > thought I could do something like: > > #!/usr/bin/env python > > import tarfile > im

Python Wrapper Tools; a Performance Study

2008-11-12 Thread Srijit Kumar Bhadra
I am looking for the file Python Wrapper Tools; a Performance Study (http://people.web.psi.ch/geus/talks/europython2004_geus.pdf). The link seems to be no longer valid. If someone has a local copy, I request him/her to share it. /Srijit -- http://mail.python.org/mailman/listinfo/python-list

Re: Single-instance daemons

2008-11-12 Thread Irmen de Jong
Jeffrey Barish wrote: Nice. One thing: how do I get the uid and gid for the target user? In general, I know the name of the target user, but the uid/gid assigned by the OS to that user could be different on different systems. pwd.getpwnam grp.getgrnam --irmen -- http://mail.python.org/mailm

<    1   2