Re: Glob in python which supports the ** wildcard

2010-11-23 Thread Simon Brunning
On 22 November 2010 21:43, Martin Lundberg wrote: > Hi, > > I want to be able to let the user enter paths like this: > > apps/name/**/*.js > > and then find all the matching files in apps/name and all its > subdirectories. However I found out that Python's glob function > doesn't support the recur

Re: Glob in python which supports the ** wildcard

2010-11-23 Thread Simon Brunning
On 23 November 2010 09:26, Martin Lundberg wrote: > It does not seem to support the ** wildcard? It will recursively seek > for files matching a pattern like *.js but it won't support > /var/name/**/*.js as root, will it? I did say roughly. ;-) You'd need to do: for filename in locate("*.js", "/

Re: Reading bz2 file into numpy array

2010-11-23 Thread Peter Otten
Nobody wrote: > On Mon, 22 Nov 2010 11:37:22 +0100, Peter Otten wrote: > >>> is there a convenient way to read bz2 files into a numpy array? >> >> Try > >> f = bz2.BZ2File(filename) >> data = numpy.fromstring(f.read(), numpy.float32) > > That's going to hurt if the file is large. Yes, but mem

Re: Python recursively __getattribute__

2010-11-23 Thread bruno.desthuilli...@gmail.com
On 22 nov, 21:44, Roman Dolgiy wrote: >> http://stackoverflow.com/questions/4247036/python-recursively-getattr... > > I need to support a lot of legacy code, with THC4k's approach I'll > have to modify project's existing code to use obj.attr1.val instead of > obj.attr1 but this is not suitable. Y

Making module content available in parent module

2010-11-23 Thread Ulrich Eckhardt
Hi! Note up front: I'm using Python2.6 still, I guess with 2.7 test discovery, I could get better results easier, right? Now, my problem is I have a directory containing test scripts which I all want to run. I used to run them individually and manually, but want to avoid this overhead in the futu

Re: Making module content available in parent module

2010-11-23 Thread Gregor Horvath
Hi, On Tue, 23 Nov 2010 11:36:05 +0100 Ulrich Eckhardt wrote: > Now, my problem is I have a directory containing test scripts which I > all want to run. I used to run them individually and manually, but > want to avoid this overhead in the future. > > tests/ >foo.py # defines TestFoo1 and

Re: Making module content available in parent module

2010-11-23 Thread Steven D'Aprano
On Tue, 23 Nov 2010 11:36:05 +0100, Ulrich Eckhardt wrote: > tests/ >foo.py # defines TestFoo1 and TestFoo2 >bar.py # defines TestBar1 and TestBar2 > > What I would like to do now is this: > > from tests import * > unittest.main() > > In other words, import all test files and run t

Re: unittests with different parameters

2010-11-23 Thread Jonathan Hartley
On Nov 22, 11:38 am, Ulrich Eckhardt wrote: > Hi! > > I'm writing tests and I'm wondering how to achieve a few things most > elegantly with Python's unittest module. > > Let's say I have two flags invert X and invert Y. Now, for testing these, I > would write one test for each combination. What I

Re: Need advices regarding the strings (str, unicode, coding) used as interface for an external library.

2010-11-23 Thread jmfauth
Thanks for the reply. Subject closed. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python recursively __getattribute__

2010-11-23 Thread Roman Dolgiy
Thanks to Andreas Waldenburger, THC4k (http://stackoverflow.com/ questions/4247036/python-recursively-getattribute) and others for their tips. I was able to find solution: class Null(object): def __repr__(self): return "" def __str__(self): return '' def __nonzero__(s

Re: Scheme as a virtual machine?

2010-11-23 Thread Keith H Duggar
On Nov 22, 5:12 pm, Raffael Cavallaro wrote: > On 2010-11-22 11:25:34 -0500, scattered said: > > > And you don't think that [JH] could write a book about Haskell > > if he honestly came to think that it were a superior all-aroung > > language? > > Until he actually does, he has a financial interes

Re: Scheme as a virtual machine?

2010-11-23 Thread Raffael Cavallaro
On 2010-11-23 10:08:12 -0500, Keith H Duggar said: There is a well-known name for such illogical reasoning: ad hominem. You don't understand ad hominem: "The ad hominem is a classic logical fallacy,[2] but it is not always fallacious. For in some instances, questions of personal conduct, ch

Re: Making module content available in parent module

2010-11-23 Thread Ulrich Eckhardt
Steven D'Aprano wrote: > On Tue, 23 Nov 2010 11:36:05 +0100, Ulrich Eckhardt wrote: >> PS: I've been trying a few things here, and stumbled across another >> thing that could provide a solution. I can "from tests import *", but >> then all these modules will pollute my namespace. I can "import test

Re: Scheme as a virtual machine?

2010-11-23 Thread Keith H Duggar
On Nov 23, 10:34 am, Raffael Cavallaro wrote: > On 2010-11-23 10:08:12 -0500, Keith H Duggar said: > > On Nov 22, 5:12 pm, Raffael Cavallaro > > wrote: > > > On 2010-11-22 11:25:34 -0500, scattered said: > > > > > > > And you don't think that [JH] could write a book about Haskell > > > > if he h

Re: Scheme as a virtual machine?

2010-11-23 Thread D'Arcy J.M. Cain
On Tue, 23 Nov 2010 10:34:22 -0500 Raffael Cavallaro wrote: > On 2010-11-23 10:08:12 -0500, Keith H Duggar said: > > There is a well-known name for such illogical reasoning: ad hominem. > You don't understand ad hominem: Perhaps you don't understand it. > "The ad hominem is a classic logical fal

Time and date operation

2010-11-23 Thread huisky
Hi everyone, Could you anybody shed lights to me? Say I have two dics. >>> cstart defaultdict(, {15424: ['Dec', '6', '18:57:40'], 552: ['Dec', '7', '09:31:00'], 15500: ['Dec', '6', '20:17:02'], 18863: ['Dec', '7', '13:14:47'], 18291: ['Dec', '6', '21:01:17'], 18969: ['Dec', '7', '14:28:42'], 18937

Re: Time and date operation

2010-11-23 Thread Chris Rebert
On Tue, Nov 23, 2010 at 9:47 AM, huisky wrote: > Hi everyone, > > Could you anybody shed lights to me? Say I have two dics. cstart > defaultdict(, {15424: ['Dec', '6', '18:57:40'], 552: > ['Dec', '7', '09:31:00'], 15500: ['Dec', '6', '20:17:02'], 18863: > ['Dec', '7', '13:14:47'], 18291: ['De

Re: Time and date operation

2010-11-23 Thread Chris Rebert
> -Original Message- > From: c...@rebertia.com [mailto: c...@rebertia.com] > Sent: 2010年11月23日 19:12 > To: huisky > Cc: python-list@python.org > Subject: Re: Time and date operation > > On Tue, Nov 23, 2010 at 9:47 AM, huisky wrote: >> Hi everyone, >> >> Could you anybody shed lights to me

Subprocess Call works on Windows, but not Ubuntu

2010-11-23 Thread Brett Bowman
I ran into an interesting problem trying to spawn a subprocess, so I thought I'd ask if the experts could explain it to me. I'm spawning a subprocess to run "pdf2txt.py", which is a tool that is distributed with PDFminer to do moderately advanced text-dumps of PDFs. Yet when I run the same code o

Re: Subprocess Call works on Windows, but not Ubuntu

2010-11-23 Thread Chris Rebert
On Tue, Nov 23, 2010 at 11:28 AM, Brett Bowman wrote: > I ran into an interesting problem trying to spawn a subprocess, so I thought > I'd ask if the experts could explain it to me.  I'm spawning a subprocess to > run "pdf2txt.py", which is a tool that is distributed with PDFminer to do > moderate

Collect output to string

2010-11-23 Thread Burton Samograd
Hello, I was wondering if there is any way in python to 'collect output to string' as in some lisps/schemes. Output being, printed output to the console using print. Thanks. -- Burton Samograd -- http://mail.python.org/mailman/listinfo/python-list

Re: Collect output to string

2010-11-23 Thread Chris Rebert
On Tue, Nov 23, 2010 at 11:53 AM, Burton Samograd wrote: > Hello, > > I was wondering if there is any way in python to 'collect output to > string' as in some lisps/schemes.  Output being, printed output to the > console using print. Rebind sys.stdout to a StringIO object. http://docs.python.org/

Re: Subprocess Call works on Windows, but not Ubuntu

2010-11-23 Thread Brett Bowman
Ah, that fixed it. Thank you. On Tue, Nov 23, 2010 at 11:37 AM, Chris Rebert wrote: > On Tue, Nov 23, 2010 at 11:28 AM, Brett Bowman wrote: > > I ran into an interesting problem trying to spawn a subprocess, so I > thought > > I'd ask if the experts could explain it to me. I'm spawning a subp

Re: Collect output to string

2010-11-23 Thread Burton Samograd
Chris Rebert writes: > On Tue, Nov 23, 2010 at 11:53 AM, Burton Samograd wrote: >> Hello, >> >> I was wondering if there is any way in python to 'collect output to >> string' as in some lisps/schemes.  Output being, printed output to the >> console using print. > > Rebind sys.stdout to a StringI

Re: Collect output to string

2010-11-23 Thread MRAB
On 23/11/2010 20:59, Burton Samograd wrote: Chris Rebert writes: On Tue, Nov 23, 2010 at 11:53 AM, Burton Samograd wrote: Hello, I was wondering if there is any way in python to 'collect output to string' as in some lisps/schemes. Output being, printed output to the console using print.

progamming approach review, child processes

2010-11-23 Thread astar
So I have not done much with child processes before. I have an input of programs to be updated, a child process that does the compiles and links (with a log output to an individual file), and a process wait at the end. Except the child process can hang (at the moment, the problem that might show

Re: Collect output to string

2010-11-23 Thread Ian
On Nov 23, 1:59 pm, Burton Samograd wrote: > Thanks for the tip.  Here's my function: > > def with_output_to_string(f, args): >      oldstdout = sys.stdout >      buffer = StringIO.StringIO() >      sys.stdout = buffer >      apply(f, args) >      sys.stdout = oldstdout >      return buffer.getval

Re: Collect output to string

2010-11-23 Thread Chris Rebert
On Tue, Nov 23, 2010 at 1:15 PM, Ian wrote: > On Nov 23, 1:59 pm, Burton Samograd wrote: >> Thanks for the tip.  Here's my function: >> >> def with_output_to_string(f, args): >>      oldstdout = sys.stdout >>      buffer = StringIO.StringIO() >>      sys.stdout = buffer >>      apply(f, args) >>

Re: Collect output to string

2010-11-23 Thread Terry Reedy
On 11/23/2010 3:02 PM, Chris Rebert wrote: On Tue, Nov 23, 2010 at 11:53 AM, Burton Samograd wrote: Hello, I was wondering if there is any way in python to 'collect output to string' as in some lisps/schemes. Output being, printed output to the console using print. Rebind sys.stdout to a St

Re: Scheme as a virtual machine?

2010-11-23 Thread Ertugrul Söylemez
Keith H Duggar wrote: > It is a common refuge of those who cannot support their position with > fact and logic. On more than one occasion Jon Harrop has all but > crushed Ertugrul in this very forum with /source code/; that is as > objective as it gets. Since Jon has financial reasons to invest

Re: CGI FieldStorage instances?

2010-11-23 Thread Gnarlodious
On Nov 22, 11:32 pm, Dennis Lee Bieber wrote: >         Or upgrade to some modernistic framework wherein the application is > a monolithic program and the "name/" portion maps to methods/functions > within the application... Yes, that describes what I am looking for! Is there such a modernistic f

Re: CGI FieldStorage instances?

2010-11-23 Thread Ian Kelly
On 11/23/2010 7:01 PM, Gnarlodious wrote: On Nov 22, 11:32 pm, Dennis Lee Bieber wrote: Or upgrade to some modernistic framework wherein the application is a monolithic program and the "name/" portion maps to methods/functions within the application... Yes, that describes what I am l

Arrays

2010-11-23 Thread Garland Fulton
Is there a way I can define an Array of and unknown size so I can add and remove to or from it? Are arrays immutable? -- http://mail.python.org/mailman/listinfo/python-list

Re: Arrays

2010-11-23 Thread Ian Kelly
On 11/23/2010 10:55 PM, Garland Fulton wrote: Is there a way I can define an Array of and unknown size so I can add and remove to or from it? Do you mean the arrays of the array module, or NumPy arrays, or something else entirely? In the first case, yes; arrays behave more or less like lists

Ensuring symmetry in difflib.SequenceMatcher

2010-11-23 Thread John Yeung
I'm generally pleased with difflib.SequenceMatcher: It's probably not the best available string matcher out there, but it's in the standard library and I've seen worse in the wild. One thing that kind of bothers me is that it's sensitive to which argument you pick as "seq1" and which you pick as