Nested Function Question

2012-01-06 Thread GZ
encing newfunc, then everything should be freed. Thanks, GZ -- http://mail.python.org/mailman/listinfo/python-list

Test None for an object that does not implement ==

2011-12-24 Thread GZ
)==(not c), but I think this code has other issues, for example, when a=[] and c=['a'], the assertion will fail, although a is not None. So how do I reliably test if a value is None or not? Thanks, gz -- http://mail.python.org/mailman/listinfo/python-list

Re: Generator Question

2011-12-24 Thread GZ
I see. Thanks for the clarification. On Dec 22, 12:35 am, Steven D'Aprano wrote: > On Wed, 21 Dec 2011 21:45:13 -0800, GZ wrote: > > Now the question here is this: > > > def h(): > >     if condition=true: > >        #I would like to return an iter

Generator Question

2011-12-21 Thread GZ
met, I want to yield nothing. How to do? Thanks, gz -- http://mail.python.org/mailman/listinfo/python-list

Re: How to Get Data from DictReader for CSV Files

2011-11-21 Thread GZ
Hi, On Nov 21, 7:42 am, ray wrote: > I don't see how to get my data from the output.  I can see the data in > the rows but it is mixed in with the field names.  That is, the data I > get comes out as: > fieldname1 : data1 , fieldname2 : data2 , etc. > > import csv > linelist=open( "C:/Users/me/li

Close as Many Files/External resourcs as possible in the face of exceptions

2011-11-20 Thread GZ
etter way of handling such situation? Thanks, gz -- http://mail.python.org/mailman/listinfo/python-list

Re: Dynamically Generate Methods

2011-11-20 Thread GZ
Hi All, I see. It works. Thanks, GZ On Nov 18, 12:04 pm, Ian Kelly wrote: > On Fri, Nov 18, 2011 at 7:51 AM, GZ wrote: > > Hi, > > > I have a class Record and a list key_attrs that specifies the names of > > all attributes that correspond to a primary key. > >

Dynamically Generate Methods

2011-11-18 Thread GZ
A','B'], I want the generated function to be equivalent to the following: def get_key(instance_of_record): return (instance_of_record['A'],instance_of_record['B'] ) I realize I can use eval or exec to do this. But is there any other way to do this? Thanks, g

Re: minidom help -- line number

2010-08-14 Thread GZ
On Aug 14, 12:07 pm, Thomas Jollans wrote: > On Saturday 14 August 2010, it occurred to GZ to exclaim: > > > Hi All, > > > I am writing a little program that reads the minidom tree built from > > an xml file. I would like to print out the line number of the xml file &

minidom help -- line number

2010-08-13 Thread GZ
help? Thanks, gz -- http://mail.python.org/mailman/listinfo/python-list

Re: Sequential Object Store

2010-08-09 Thread GZ
Hi Alex, On Aug 7, 6:54 pm, Alex Willmer wrote: > On Aug 7, 5:26 pm, GZ wrote: > > > I am wondering if there is a module that can persist a stream of > > objects without having to load everything into memory. (For this > > reason, I think Pickle is out, too, because i

Sequential Object Store

2010-08-07 Thread GZ
data. In essence, shelve.keys() takes forever. I am wondering if there is a module that can persist a stream of objects without having to load everything into memory. (For this reason, I think Pickle is out, too, because it needs everything to be in memory.) Thanks, GZ -- http://mail.python.org

Re: Diff of Text

2010-06-05 Thread GZ
On Jun 5, 8:42 pm, Ben Finney wrote: > GZ writes: > > Let me think of a better way to express what I mean by a "smaller > >diff." After Idiffthe two strings, I will have something like this: > > >   AAA > > - BBB > > + CCC > > + DDD > >

Re: Diff of Text

2010-06-05 Thread GZ
Hi Lie, On Jun 5, 2:53 am, Lie Ryan wrote: > On 06/05/10 15:43, GZ wrote: > > > > > > > On Jun 4, 8:37 pm, Lie Ryan wrote: > >> On06/05/10 07:51, GZ wrote: > >>> No, rsync does not solve my problem. > > >>> I want a library that do

vector addition

2010-06-05 Thread GZ
Hi, I am looking for a fast internal vector representation so that (a1,b2,c1)+(a2,b2,c2)=(a1+a2,b1+b2,c1+c2). So I have a list l = ['a'a,'bb','ca','de'...] I want to count all items that start with an 'a', 'b', and 'c'. What I can do is: count_a = sum(int(x[1]=='a') for x in l) count_b = sum(

Re: Diff of Text

2010-06-04 Thread GZ
On Jun 4, 8:37 pm, Lie Ryan wrote: > On06/05/10 07:51, GZ wrote: > > > > > > > Hi Pat, > > > On Jun 4, 2:55 pm, Patrick Maupin wrote: > >> On Jun 3, 9:54 pm, GZ wrote: > > >>> Hi All, > > >>> I am looking for an algorit

Re: Diff of Text

2010-06-04 Thread GZ
Hi Pat, On Jun 4, 2:55 pm, Patrick Maupin wrote: > On Jun 3, 9:54 pm, GZ wrote: > > > Hi All, > > > I am looking for an algorithm that can compare to source code files > > line by line and find the minimum diff. I have looked at the difflib > > included in

Diff of Text

2010-06-03 Thread GZ
differencial. I would like an algorithm implementation that gives the absolute minimum difference between the two files. Can you help me? Thanks, gz -- http://mail.python.org/mailman/listinfo/python-list

Remembering the context

2010-04-28 Thread GZ
Hi All, I am looking at the following code: def fn(): def inner(x): return tbl[x] tbl={1:'A', 2:'B'} f1 = inner # I want to make a frozen copy of the values of tbl in f1 tbl={1:'C', 2:'D'} f2 = inner return (f1,f2) f1,f2 = fn() f1(1) # output C f2(1) # output

Re: How to use a class property to store function variables?

2010-04-28 Thread GZ
On Apr 28, 1:20 am, Chris Rebert wrote: > On Tue, Apr 27, 2010 at 11:02 PM, GZ wrote: > > On Apr 27, 9:20 pm, alex23 wrote: > >> GZ wrote: > >> > I do not think it will help me. I am not trying to define a function > >> > fn() in the class, but rath

Re: How to use a class property to store function variables?

2010-04-27 Thread GZ
On Apr 27, 9:20 pm, alex23 wrote: > GZ wrote: > > I do not think it will help me. I am not trying to define a function > > fn() in the class, but rather I want to make it a "function reference" > > so that I can initialize it any way I like later. > > It a

Re: How to use a class property to store function variables?

2010-04-27 Thread GZ
On Apr 27, 9:20 pm, alex23 wrote: > GZ wrote: > > I do not think it will help me. I am not trying to define a function > > fn() in the class, but rather I want to make it a "function reference" > > so that I can initialize it any way I like later. > > It a

Re: How to use a class property to store function variables?

2010-04-27 Thread GZ
Hi Chris, On Apr 27, 6:43 pm, Chris Rebert wrote: > On Tue, Apr 27, 2010 at 4:36 PM, GZ wrote: > > I want to store a reference to a function into a class property. > > > So I am expecting that: > > > class A: > >     fn = lambda x: x > > > fn = A.fn &

How to use a class property to store function variables?

2010-04-27 Thread GZ
t instance instead) The problem is that A.fn is treated as a bounded method. I really want A.fn to be a variable that stores a reference to a function. Is there any way to achieve this? Thanks, GZ -- http://mail.python.org/mailman/listinfo/python-list

pyopenglcontext binaries for 2.5 on win32

2007-11-12 Thread gz
no, I don't have them... I need them :) I'd like to thank Giovanni Bajo for providing binaries for the various package dependencies, and geting me going with pyopengl. Unfortunately I only menaged to run a basic example, where there's no animation. The glwindow only get's redrawn when it's resize

low level python read's

2007-01-07 Thread gz
Hi! I wanted to use python to test a simple character device (on linux) and I'm running into strange behaviour of read.. I have a short buffer inside my device and the idea is that it blocks read's when the buffer is empty. For reads that ask for more characters that the buffer holds the device sh