Re: Recursive function returning a list

2006-07-18 Thread malkarouri
Bruno Desthuilliers wrote: > Boris Borcic a écrit : > > Hello Bruno, > > > > Bruno Desthuilliers wrote: > > > >> Boris Borcic wrote: > >> > Do you have any ideas? > >>> > >>> > >>> you could use a recursive generator, like > >>> > >>> def genAllChildren(self) : > >>> for child in self.chil

Re: Recursive function returning a list

2006-07-19 Thread malkarouri
Bruno Desthuilliers wrote: > [EMAIL PROTECTED] wrote: [...] > > Sorry, but I kinda agree with Boris here. > > On what ? On the argument that you are (implicitly?) disagreeing with him on, obviously. That the OP problem is not definitely the default values question. As you say: > >>If the OP has o

Re: how to implementation latent semantic indexing in python..

2007-07-18 Thread malkarouri
On 13 Jul, 17:18, 78ncp <[EMAIL PROTECTED]> wrote: > hi... > how to implementation algorithm latent semantic indexing in python > programming...?? > > thank's for daniel who answered my question before.. > > -- > View this message in > context:http://www.nabble.com/how-to-implementation-latent-sem

Re: Python Memory Usage

2007-06-30 Thread malkarouri
On Jun 20, 4:48 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I am using Python to process particle data from a physics simulation. > There are about 15 MB of data associated with each simulation, but > there are many simulations. I read the data from each simulation into > Numpy arrays and

run function in separate process

2007-04-11 Thread malkarouri
Hi everyone, I have written a function that runs functions in separate processes. I hope you can help me improving it, and I would like to submit it to the Python cookbook if its quality is good enough. I was writing a numerical program (using numpy) which uses huge amounts of memory, the memory

Re: run function in separate process

2007-04-11 Thread malkarouri
Thanks Mike for you answer. I will use the occasion to add some comments on the links and on my approach. I am programming in Python 2.5, mainly to avoid the bug that memory arenas were never freed before. The program is working on both Mac OS X (intel) and Linux, so I prefer portable approaches.

Re: run function in separate process

2007-04-11 Thread malkarouri
On Apr 11, 3:58 pm, [EMAIL PROTECTED] (Alex Martelli) wrote: [...] > That's my favorite way to ensure that all resources get reclaimed: let > the operating system do the job. Thanks a lot, Alex, for confirming the basic idea. I will be playing with your function later today, and will give more fee

Re: run function in separate process

2007-04-11 Thread malkarouri
On Apr 11, 4:36 pm, [EMAIL PROTECTED] wrote: [...] > .. And I avoided pickle at the time > because I had a structure that was unpicklable (grown by me using a > mixture of python, C, ctypes and pyrex at the time). The structure is > improved now, and I will go for the more standard approach.. Sorr

Re: run function in separate process

2007-04-11 Thread malkarouri
After playing with Alex's implementation, and adding some support for exceptions, this is what I came up with. I hope I am not getting too clever for my needs: import os, cPickle def run_in_separate_process_2(f, *args, **kwds): pread, pwrite = os.pipe() pid = os.fork() if pid > 0:

Re: run function in separate process

2007-04-11 Thread malkarouri
After playing a little with Alex's function, I got to: import os, cPickle def run_in_separate_process_2(f, *args, **kwds): pread, pwrite = os.pipe() pid = os.fork() if pid > 0: os.close(pwrite) with os.fdopen(pread, 'rb') as f: status, result = cPickle.load(

Re: Problem with Closing TCP connection

2007-05-05 Thread malkarouri
On 5 May, 12:18, Madhur <[EMAIL PROTECTED]> wrote: [...] > as a sink to pump TCP messages. During which i have observed that the > TCP close interface provided by Python is not closing the connection. > This i confirmed by looking at the ethereal logs, which show proper 3 > way FIN ACK Handshake. B

Re: Starting out.

2006-10-12 Thread malkarouri
Ahmer wrote: > Hi all! > > I am a 15 year old High School Sophomore. I would like to start > programming in Python. In school, we are learning Java (5) and I like > to use the Eclipse IDE, I also am learning PHP as well. > > What are some ways to get started (books, sites, etc.)? I am usually on >

identifying new not inherited methods

2006-09-26 Thread malkarouri
Hi, I am writing a library in which I need to find the names of methods which are implemented in a class, rather than inherited from another class. To explain more, and to find if there is another way of doing it, here is what I want to do: I am defining two classes, say A and B, as: class A(obje

Re: identifying new not inherited methods

2006-09-26 Thread malkarouri
George Sakkis wrote: [...] > I'd rather have it as a function, not attached to a specific class: > Thanks a lot George, that was what I was looking for. Got to understand/appreciate inspect more. Of course it works as a method. So, other than having it as a general utility, I presume there is no s

Re: identifying new not inherited methods

2006-09-27 Thread malkarouri
George Sakkis wrote: [...] > You're looking at it backwards; there's no particular reason this > should be a method of class A since it can be used for any arbitrary > object with no extra overhead. Now, if you intend to use it only for > instances of A and its subclasses, the only difference would

Is PEP 237 accepted?

2005-11-10 Thread malkarouri
I was just having a pass on the peps when I noticed that the Unifying Long Integers and Integers PEP is still draft. With most of it already implemented - I understand banning the trailing 'L' is the only thing left, shouldn't it at least be flagged as Accepted, if not Final? karouri -- http://m

Re: Considering moving from Delphi to Python [Some questions]

2005-07-06 Thread malkarouri
Dark Cowherd wrote: > Stupid of me. > > I want some feedback on folllwing: > anybody who has experience in writing SOAP servers in Python and data > entry heavy web applications. > Any suggestions? > darkcowherd Check ZSI, or SOAPPY, both on Python Web Services http://pywebsvcs.sourceforge.net/ I

Re: Tripoli: a Python-based triplespace implementation

2005-05-01 Thread malkarouri
Dominic Fox wrote: > I have been working on a Python implementation of a modified Tuple > Space (cf Linda, JavaSpaces) that contains only 3-tuples (triples), > and that has operators for copying and moving graphs of triples as > well as sets matching a given pattern. It's called Tripoli, ... Inter

Re: Why shouldn't you put config options in py files

2008-12-04 Thread malkarouri
On 4 Dec, 19:35, HT <[EMAIL PROTECTED]> wrote: > A colleague of mine is arguing that since it is easy to write config like: > > FOO = {'bar': ('a': 'b'), 'abc': ('z': 'x')} > > in config.py and just import it to get FOO, but difficult to achieve the > same using an ini file and ConfigParser, and si

Re: RELEASED Python 2.6.1

2008-12-05 Thread malkarouri
On 5 Dec, 05:07, Barry Warsaw <[EMAIL PROTECTED]> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Hot on the heals of Python 3.0 comes the Python 2.6.1 bug-fix   > release. Nice work. Thanks. > Source tarballs and Windows installers can be downloaded from the   > Python 2.6.1 page I

Re: how to get a beep, OS independent ?

2008-12-08 Thread malkarouri
On 6 Dec, 23:40, Stef Mientki <[EMAIL PROTECTED]> wrote: > hello, > > I want to give a small beep, Just to add to the options here. Where ncurses work you can use: python -c 'from curses import *;wrapper(lambda s:beep())' To try it just enter the whole line above in the command line.. Regards,

Re: When (and why) to use del?

2008-12-09 Thread malkarouri
On 9 Dec, 16:35, Albert Hopkins <[EMAIL PROTECTED]> wrote: > I'm looking at a person's code and I see a lot of stuff like this: > >         def myfunction(): >             # do some stuff stuff >             my_string = function_that_returns_string() >             # do some stuff with my_string >  

Re: Large Data Sets: Use base variables or classes? And some binding questions

2008-09-26 Thread malkarouri
On 26 Sep, 16:39, Patrick Sullivan <[EMAIL PROTECTED]> wrote: > Hello. > > I will be using some large data sets ("points" from 2 to 12 variables) > and would like to use one class for each point rather than a list or > dictionary. I imagine this is terribly inefficient, but how much? I can't real

List as FIFO in for loop

2008-03-08 Thread malkarouri
Hi everyone, I have an algorithm in which I need to use a loop over a queue on which I push values within the loop, sort of: while not(q.empty()): x = q.get() #process x to get zero or more y's #for each y: q.put(y) The easiest thing I can do is use a list as a queue and a normal

Re: List as FIFO in for loop

2008-03-08 Thread malkarouri
On Mar 8, 3:20 pm, Roel Schroeven <[EMAIL PROTECTED]> wrote: > malkarouri schreef: > > > > > Hi everyone, > > > I have an algorithm in which I need to use a loop over a queue on > > which I push values within the loop, sort of: > > > while not(q.emp

Re: List as FIFO in for loop

2008-03-08 Thread malkarouri
On Mar 8, 3:52 pm, duncan smith <[EMAIL PROTECTED]> wrote: > malkarouri wrote: > > Hi everyone, > > > I have an algorithm in which I need to use a loop over a queue on > > which I push values within the loop, sort of: > > > while not(q.empty()): > >  

Re: List as FIFO in for loop

2008-03-08 Thread malkarouri
On Mar 8, 4:44 pm, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: ... > Notice that the language specification *deliberately* does not > distinguish between deletion of earlier and later items, but > makes modification of the sequence undefined behavior to allow > alternative implementations. E.g. an

Re: List as FIFO in for loop

2008-03-08 Thread malkarouri
On Mar 8, 6:24 pm, rockingred <[EMAIL PROTECTED]> wrote: > I think it's a bad practice to get into.  Did you intend to do the > "process" step again over the added variables?  If not I would set a > new variable, based on your awful naming convention, let's call it z. > Then use z.append(y) within

CPython and a C extension using Boehm GC

2007-12-25 Thread malkarouri
Hi everyone, Is it possible to write a Python extension that uses the Boehm garbage collector? I have a C library written that makes use of boehm-gc for memory management. To use that, I have to call GC_INIT() at the start of the program that uses the library. Now I want to encapsulate the library

Re: SoC project: Python-Haskell bridge - request for feedback

2008-03-27 Thread malkarouri
On 26 Mar, 08:46, Paul Rubin wrote: > A few thoughts. The envisioned Python-Haskell bridge would have two > directions: 1) calling Haskell code from Python; 2) calling Python > code from Haskell. The proposal spends more space on #1 but I think > #1 is both more difficu

Re: function that accepts any amount of arguments?

2008-04-24 Thread malkarouri
On Apr 24, 12:43 pm, Bruno Desthuilliers wrote: [...] > Not quite sure what's the best thing to do in the second case - raise a > ValueError if args is empty, or silently return 0.0 - but I'd tend to > choose the first solution (Python's Zen, verses 9-11). What's wrong with raising ZeroDivisionEr