Re: Autogenerate functions (array of lambdas)

2007-09-06 Thread Chris Johnson
On Sep 6, 3:44 am, Paul Rubin <http://[EMAIL PROTECTED]> wrote: > Chris Johnson <[EMAIL PROTECTED]> writes: > > a = [lambda: i for i in range(10)] > > print [f() for f in a] > > results in: [9, 9, 9, 9, 9, 9, 9, 9, 9, 9] > > rather than the hoped for: [0, 1

Autogenerate functions (array of lambdas)

2007-09-06 Thread Chris Johnson
What I want to do is build an array of lambda functions, like so: a = [lambda: i for i in range(10)] (This is just a demonstrative dummy array. I don't need better ways to achieve the above functionality.) print [f() for f in a] results in: [9, 9, 9, 9, 9, 9, 9, 9, 9, 9] rather than the hoped f

Re: Generating all permutations from a regexp

2006-12-23 Thread Chris Johnson
Thomas Ploch wrote: > Fredrik Lundh wrote: > > Nick Craig-Wood wrote: > > > >> A regular expression matcher uses a state machine to match strings. > > > > unless it's the kind of regular expression matcher that doesn't use a > > state machine, like the one in Python. > > > > > > > > How is the ma

Re: Generating all permutations from a regexp

2006-12-23 Thread Chris Johnson
BJörn Lindqvist wrote: > With regexps you can search for strings matching it. For example, > given the regexp: "foobar\d\d\d". "foobar123" would match. I want to > do the reverse, from a regexp generate all strings that could match > it. > > The regexp: "[A-Z]{3}\d{3}" should generate the strings

Re: Ok. This IS homework ...

2006-10-14 Thread Chris Johnson
spawn wrote: > but I've been struggling with this for far too long and I'm about to > start beating my head against the wall. > > My assignment seemed simple: create a program that will cacluate the > running total of user inputs until it hits 100. At 100 it should stop. > That's not the problem

Re: Small Troll on notation of variables over time

2006-08-19 Thread Chris Johnson
Hendrik van Rooyen wrote: > Hi there, > > I can write: > > s = 'some string' > then print s[1] will be the string 'o' > > and a while later I can write: > > s = 'other some string' > then print s[1] will be the string 't' > > and then: > > s = [1,2,3,4] > then print s[1] will be the number 2 > > a

Re: is it possible to dividing up a class in multiple files?

2006-08-07 Thread Chris Johnson
Martin Höfling wrote: > Hi there, > > is it possible to put the methods of a class in different files? I just > want to order them and try to keep the files small. > > Regards > Martin I ran across pyp the other day. It may be what you're wanting. http://www.freenet.org.nz/python/pyp/ --

PyGTK TreeView segmentation fault on expand_all()

2006-08-07 Thread Chris Johnson
Good morning. I have recently begun a project using PyGTK, and part of my planned interface has a gtk.TreeView showing a portion of the filesystem. Now, rather than load the entire FS structure into the tree right from the beginning, I made a lazy tree by adding blank children to rows representing