tracking variable value changes

2011-12-08 Thread Catherine Moroney
Hello, Is there a way to create a C-style pointer in (pure) Python so the following code will reflect the changes to the variable "a" in the dictionary "x"? For example: >>> a = 1.0 >>> b = 2.0 >>> x = {"a":a, "b":b} >>> x {'a': 1.0, 'b': 2.0} >>> a = 100.0 >>> x {'a': 1.0, 'b': 2.0} ## at

Re: Python advanced course (preferably in NA)

2011-11-03 Thread Catherine Moroney
I've taken two Python classes from David Beazley and can second Eric's recommendation. The "advanced" class is really advanced and goes into some pretty mind-blowing stuff. The class comes with lots of problems and solutions, and a book of all the slides which are a great reference. Well worth

Re: Python advanced course (preferably in NA)

2011-11-03 Thread Catherine Moroney
I've taken two Python classes from David Beazley and can second Eric's recommendation. The "advanced" class is really advanced and goes into some pretty mind-blowing stuff. The class comes with lots of problems and solutions, and a book of all the slides which are a great reference. Well worth

fast copying of large files in python

2011-11-02 Thread Catherine Moroney
Hello, I'm working on an application that as part of its processing, needs to copy 50 Meg binary files from one NFS mounted disk to another. The simple-minded approach of shutil.copyfile is very slow, and I'm guessing that this is due to the default 16K buffer size. Using shtil.copyfileobj

using masks and numpy record arrays

2011-05-25 Thread Catherine Moroney
Hello, I am trying to work with a structured array and a mask, and am encountering some problems. For example: >>> xtype = numpy.dtype([("n", numpy.int32), ("x", numpy.float32)]) >>> a = numpy.zeros((4), dtype=xtype) >>> b = numpy.arange(0,4) >>> a2 = numpy.zeros((4), dtype=xtype) >>> mask =

importing class objects from a pickled file

2011-05-03 Thread Catherine Moroney
Hello, I have an object of class X that I am writing to a pickled file. The pickling part goes fine, but I am having some problems reading the object back out, as I get complaints about "unable to import module X". The only way I have found around it is to run the read-file code out of the

Re: order of importing modules

2011-01-12 Thread Catherine Moroney
pyhdfeos-1.0_r57_58-py2.5-linux-x86_64.egg variable showing up as one of the first entries in sys.path. Thanks for the education, Catherine Dan Stromberg wrote: On Tue, Jan 11, 2011 at 4:30 PM, Catherine Moroney wrote: In what order does python import modules on a Linux system? I have a packa

Re: order of importing modules

2011-01-12 Thread Catherine Moroney
pyhdfeos-1.0_r57_58-py2.5-linux-x86_64.egg variable showing up as one of the first entries in sys.path. Thanks for the education, Catherine Dan Stromberg wrote: On Tue, Jan 11, 2011 at 4:30 PM, Catherine Moroney wrote: In what order does python import modules on a Linux system? I have a packa

order of importing modules

2011-01-11 Thread Catherine Moroney
In what order does python import modules on a Linux system? I have a package that is both installed in /usr/lib64/python2.5/site-packages, and a newer version of the same module in a working directory. I want to import the version from the working directory, but when I print module.__file__ in

Re: getting a string as the return value from a system command

2010-04-16 Thread Catherine Moroney
Robert Kern wrote: On 2010-04-16 14:06 PM, Catherine Moroney wrote: Hello, I want to call a system command (such as uname) that returns a string, and then store that output in a string variable in my python program. What is the recommended/most-concise way of doing this? I could always

getting a string as the return value from a system command

2010-04-16 Thread Catherine Moroney
Hello, I want to call a system command (such as uname) that returns a string, and then store that output in a string variable in my python program. What is the recommended/most-concise way of doing this? I could always create a temporary file, call the "subprocess.Popen" module with the tempora

uniqueness of temporary files generated by tempfile

2009-03-06 Thread Catherine Moroney
Are the temporary filenames generated by the tempfile module guaranteed to be unique? I have a need to generate temporary files within an application, and I will have many instances of this application running as a sub-process (so I can submit them to a batch queue). Is there any danger of my di

Re: executing multiple functions in background simultaneously

2009-01-14 Thread Catherine Moroney
On Jan 14, 2009, at 5:20 PM, Jean-Paul Calderone wrote: On Wed, 14 Jan 2009 17:11:44 -0800, Catherine Moroney wrote: [snip] The easy thing is to use a Queue object. The background thread uses .put() to place a computed result on the QUeue and the caller uses .get() to read from the queue

Re: executing multiple functions in background simultaneously

2009-01-14 Thread Catherine Moroney
Cameron Simpson wrote: On 14Jan2009 15:50, Catherine Moroney wrote: James Mills wrote: On Wed, Jan 14, 2009 at 11:02 AM, Catherine Moroney wrote: I would like to spawn off multiple instances of a function and run them simultaneously and then wait until they all complete. [...] Try using

Re: executing multiple functions in background simultaneously

2009-01-14 Thread Catherine Moroney
James Mills wrote: On Wed, Jan 14, 2009 at 11:02 AM, Catherine Moroney wrote: I would like to spawn off multiple instances of a function and run them simultaneously and then wait until they all complete. Currently I'm doing this by calling them as sub-processes executable from the command

executing multiple functions in background simultaneously

2009-01-13 Thread Catherine Moroney
Hello everybody, I know how to spawn a sub-process and then wait until it completes. I'm wondering if I can do the same thing with a Python function. I would like to spawn off multiple instances of a function and run them simultaneously and then wait until they all complete. Currently I'm doing

Re: calling python scripts as a sub-process

2008-11-19 Thread Catherine Moroney
Dan Upton wrote: On Wed, Nov 19, 2008 at 2:38 PM, Catherine Moroney <[EMAIL PROTECTED]> wrote: Dan Upton wrote: On Wed, Nov 19, 2008 at 2:13 PM, Philip Semanchuk <[EMAIL PROTECTED]> wrote: On Nov 19, 2008, at 2:03 PM, Catherine Moroney wrote: The command (stored as an array of s

Re: calling python scripts as a sub-process

2008-11-19 Thread Catherine Moroney
Dan Upton wrote: On Wed, Nov 19, 2008 at 2:13 PM, Philip Semanchuk <[EMAIL PROTECTED]> wrote: On Nov 19, 2008, at 2:03 PM, Catherine Moroney wrote: The command (stored as an array of strings) that I'm executing is: ['python ../src_python/Match1.p

Re: calling python scripts as a sub-process

2008-11-19 Thread Catherine Moroney
x27;] sub1 = subprocess.Popen(command) Can anybody see a reason for why the abbreviated version works, and the full-up one doesn't? Catherine Philip Semanchuk wrote: On Nov 19, 2008, at 2:03 PM, Catherine Moroney wrote: The command (stored as an arr

calling python scripts as a sub-process

2008-11-19 Thread Catherine Moroney
I have one script (Match1) that calls a Fortran executable as a sub-process, and I want to write another script (Match4) that spawns off several instances of Match1 in parallel and then waits until they all finish running. The only way I can think of doing this is to call it as a sub-process, ra

memory use with regard to large pickle files

2008-10-15 Thread Catherine Moroney
I'm writing a python program that reads in a very large "pickled" file (consisting of one large dictionary and one small one), and parses the results out to several binary and hdf files. The program works fine, but the memory load is huge. The size of the pickle file on disk is about 900 Meg so