Re: tough-to-explain Python

2009-07-20 Thread Paul Rubin
Simon Forman writes: > But I'm glad it's there to study, these are wheels I don't have to > invent for myself. http://dwheeler.com/essays/high-assurance-floss.html might be an interesting place to start. -- http://mail.python.org/mailman/listinfo/python-list

Re: comments? storing a function in an object

2009-07-20 Thread Esmail
Hi Francesco, Those were great suggestions! Re 1: I used the __doc__ attribute to eliminate the parameter in the constructor as you suggested. Also, much easier to specify the character string with the actual function than later to match it up like I was. class Function(object

Re: missing 'xor' Boolean operator

2009-07-20 Thread Ethan Furman
[fixed for bottom-posting] Dr. Phillip M. Feldman wrote: MRAB-2 wrote: What values should 'xor' return? IMHO, if only one of the values is true then it should return that value, otherwise it should return False. 1 xor 0 => 1 0 xor 2 => 2 1 xor 2 => False 0 xor 0 => False T

Re: are user defined classes hashable?

2009-07-20 Thread Aahz
In article <373d6c69-6965-4a88-bdd2-8028ef850...@k6g2000yqn.googlegroups.com>, Hyuga wrote: > >Regardless, Nicolas's example can be applied to the class too: > class Foo(object): > pass > hash(Foo) >11443104 id(Foo) >11443104 > >class objects are just objects of type 'type'.

Re: comments? storing a function in an object

2009-07-20 Thread Carl Banks
On Jul 20, 9:22 am, Esmail wrote: > def funct1(x): >      ''' small test function ''' >      return x * x > > def funct2(x, y): >      ''' small test function ''' >      return x + y > > def funct3(x): >      ''' small test function ''' >      return 1000 + (x*x + x) * math.cos(x) > > def main():

clean way prepend an element to a numpy array

2009-07-20 Thread bdb112
If I want to add an element at the beginning of an array, it seems like I must make a list, insert in place, then make an array again. Of course, lists can be efficient too, and the insert() funtion works nicely in that case, but sometimes arrays are the best choice e.g. x=array([1,2,3]) # to put

Re: clean way prepend an element to a numpy array

2009-07-20 Thread Ben Finney
bdb112 writes: > If I want to add an element at the beginning of an array, it seems > like I must make a list, insert in place, then make an array again. The NumPy ‘ndarray’ type (which is what you get by default from the ‘array’ factory function) is a far more complex type than (and is not deri

Re: Mechanize not recognized by py2exe

2009-07-20 Thread OrcaSoul
Gabriel Genellina-7 wrote: > > En Fri, 17 Jul 2009 15:51:11 -0300, Stephen M. Olds > escribió: > >> I have a Python script getData.py that uses Mechanize, and runs fine >> under the >> interpreter. It was installed using easy_install - and the install >> seemed to >> indicate it was comp

Re: If Scheme is so good why MIT drops it?

2009-07-20 Thread Frank Buss
Scott Burson wrote: > Have you looked at ECL? > > http://ecls.sourceforge.net/ > > I've used it only a little, so I can't vouch for its stability, but it > fits the threading and license requirements (well, some corporate > lawyers have trouble with the LGPL, but I think it's usable). I didn't

ignore special characters in python regex

2009-07-20 Thread Astan Chee
Hi, I'm reading text from a file (per line) and I want to do a regex using these lines but I want the regex to ignore any special characters and treat them like normal strings. Is there a regex function that can do this? Here is what I have so far: fp = open('file.txt','r') notes = fp.readlines

Re: any suggestions to synchronize typed text and speech ?

2009-07-20 Thread Frank Buss
Stef Mientki wrote: > Here the problem part: > I need to synchronize the typed text with the sound during playback. > So if I click somewhere in the sound recording, > the line of text, typed that moment should be highlighted. > And vise versa, if the cursor in the text is moved and some special k

C-API, tp_dictoffset vs tp_members

2009-07-20 Thread Ulrich Eckhardt
Hi! When would I use PyObject_SetAttrString/tp_dictoffset instead of tp_members? I have a predefined set of members, some of which are optional. The problem I had with an embedded dictionary was that I can't see its elements using "dir()". Now I just converted to using tp_members, and it still

Re: ignore special characters in python regex

2009-07-20 Thread Frank Buss
Astan Chee wrote: > I'm reading text from a file (per line) and I want to do a regex using > these lines but I want the regex to ignore any special characters and > treat them like normal strings. > Is there a regex function that can do this? Maybe re.escape helps? -- Frank Buss, f...@frank-b

Re: clean way prepend an element to a numpy array

2009-07-20 Thread bdb112
On Jul 21, 2:13 pm, Ben Finney wrote: > bdb112 writes: > > If I want to add an element at the beginning of an array, it seems > > like I must make a list, insert in place, then make an array again. > > The NumPy ‘ndarray’ type (which is what you get by default from the > ‘array’ factory function)

Re: ignore special characters in python regex

2009-07-20 Thread John Machin
On Jul 21, 3:02 pm, Astan Chee wrote: > Hi, > I'm reading text from a file (per line) and I want to do a regex using > these lines but I want the regex to ignore any special characters and > treat them like normal strings. > Is there a regex function that can do this? It would help if you were to

Re: any suggestions to synchronize typed text and speech ?

2009-07-20 Thread Che M
On Jul 19, 4:15 pm, Stef Mientki wrote: > hello, > > I'm using Scintilla as a wxPython widget with great pleasure. > I now have an application where I want to make notes during a conversation, > but also want to record the speech during that conversation. > I'm using Scintilla as a wxPython widget

Re: comments? storing a function in an object

2009-07-20 Thread I V
On Mon, 20 Jul 2009 21:53:59 -0400, Esmail wrote: > In general I would agree with you, but in my specific case I want so > store some additional meta-data with each function, such as the valid > range for input values, where the max or minimum are located, the > name/source for the function etc. I

python function for retrieving key and encryption

2009-07-20 Thread jayshree
M2Crypto package not showing the 'recipient_public_key.pem' file at linux terminal .how do i get/connect with recipient public key. exactly i need to check how can i open this file through linux commands. import M2Crypto def encrypt(): recip = M2Crypto.RSA.load_pub_key(open ('recipient_public_key

Re: Why aren't OrderedDicts comparable with < etc?

2009-07-20 Thread Jack Diederich
On Mon, Jul 20, 2009 at 10:00 AM, Steven D'Aprano wrote: > On Mon, 20 Jul 2009 09:34:24 +, Sion Arrowsmith wrote: > >> Terry Reedy   wrote: >>>Sion Arrowsmith wrote: Jack Diederich   wrote: > It isn't an OrderedDict thing, it is a comparison thing.  Two regular > dicts also raise a

Re: comments? storing a function in an object

2009-07-20 Thread Gabriel Genellina
En Mon, 20 Jul 2009 22:53:59 -0300, Esmail escribió: Gabriel Genellina wrote: > If you follow the above suggestions, you'll see that your Function class becomes almost useless: a normal function already IS an object, so you don't have to wrap it inside ANOTHER object unless you need very

<    1   2