What is equivalent of *this = that in python?

2007-06-01 Thread Emin.shopper Martinian.shopper
Dear Experts, How do I reassign self to another object? For example, I want something like class foo: def Update(self,other): # make this object the same as other or make this object a copy of other self = other # This won't work. What I really want is *this = other in C++ termi

Re: What is equivalent of *this = that in python?

2007-06-01 Thread Emin.shopper Martinian.shopper
r way... Thanks, -Emin On 6/1/07, Carsten Haese <[EMAIL PROTECTED]> wrote: On Fri, 2007-06-01 at 11:30 -0400, Emin.shopper Martinian.shopper wrote: > Dear Experts, > > How do I reassign self to another object? For example, I want > something like > > class foo: > def Upda

how does one use pdb and doctest.testmod(raise_on_error=True)?

2007-06-19 Thread Emin.shopper Martinian.shopper
Dear Experts, How does one use pdb and doctest.testmod(raise_on_error=True)? What I would like to happen is that when a doctest fails (e.g., by raising an exception), I can do import pdb; pdb.pm() to figure out what went wrong. But when I do pdb.pm() I end up in doctest.DebugRunner.report_unexpec

What is the preferred doc extraction tool?

2007-07-09 Thread Emin.shopper Martinian.shopper
Dear Experts, What is the preferred doc extraction tool for python? It seems that there are many very nice options (e.g., pydoc, epydoc, HappyDoc, and lots of others), but what is the "standard" tool or at least what is the tool used to generate the documentation for the python standard library?

Re: profiling a C++ python extension

2007-07-11 Thread Emin.shopper Martinian.shopper
Googling for "profiling python extensions" leads to the following link which worked for me a while ago: http://plexity.blogspot.com/2006/02/profiling-python-extensions.html On 7/10/07, rasmus <[EMAIL PROTECTED]> wrote: I have used gprof to profile stand alone C++ programs. I am also aware of p

How do you debug when a unittest.TestCase fails?

2007-07-18 Thread Emin.shopper Martinian.shopper
Dear Experts, How do you use pdb to debug when a TestCase object from the unittest module fails? Basically, I'd like to run my unit tests and invoke pdb.pm when something fails. I tried the following with now success: Imagine that I have a module _test.py that looks like the following: ---

Re: How do you debug when a unittest.TestCase fails?

2007-07-18 Thread Emin.shopper Martinian.shopper
() File "c:\python25\lib\pdb.py", line 1148, in pm post_mortem(sys.last_traceback) AttributeError: 'module' object has no attribute 'last_traceback' On 7/18/07, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: On Wed, 18 Jul 2007 16:40:46 -0400, "Emin.sh

Re: How do you debug when a unittest.TestCase fails?

2007-07-19 Thread Emin.shopper Martinian.shopper
seems like an ugly hack and I would think there is a better solution... Thanks, -Emin On 7/18/07, Emin.shopper Martinian.shopper <[EMAIL PROTECTED]> wrote: Thanks for the reply, but neither of those work for me. I don't seem to have the "trial" program installed. Where

which python mode to use in emacs

2007-09-21 Thread Emin.shopper Martinian.shopper
Dear Experts, There seem to be multiple versions of python modes for emacs? Could someone point me to the mainterers of either the "official" one or the one that is being maintained most vigorously? I've tried both python.el and python-mode.el. Both seem to have various minor foibles which I'd be

How can you make pylint/pychecker "see" setattr

2007-12-11 Thread Emin.shopper Martinian.shopper
Dear Experts, Does anyone know how you can either make pylint "see" setattr or give it explicit information when you do a "compile time" call to setattr? For example, imagine that I have the following block of code class foo: def __init__(self): for i in [1,2,5]: setattr(s

problem pickling a function

2007-12-12 Thread Emin.shopper Martinian.shopper
Dear Experts, I love the pickle module, but I occasionally have problems pickling a function. For example, if I create an instance g of class f and assign g.xto a function, then I cannot pickle g (example code below). I know that I can pickle f separately if I want to, and I understand why I get t

Re: problem pickling a function

2007-12-12 Thread Emin.shopper Martinian.shopper
On Dec 12, 2007 11:48 AM, Calvin Spealman <[EMAIL PROTECTED]> wrote: > On Dec 12, 2007, at 11:01 AM, Emin.shopper Martinian.shopper wrote: > > > But is there a way to assign functions to instances of a class > > without preventing pickleability? It doesn't seem unre

parallel processing in standard library

2007-12-27 Thread Emin.shopper Martinian.shopper
Dear Experts, Is there any hope of a parallel processing toolkit being incorporated into the python standard library? I've seen a wide variety of toolkits each with various features and limitations. Unfortunately, each has its own API. For coarse-grained parallelism, I suspect I'd be pretty happy

Re: parallel processing in standard library

2007-12-28 Thread Emin.shopper Martinian.shopper
On Dec 27, 2007 4:13 PM, Robert Kern <[EMAIL PROTECTED]> wrote: > Emin.shopper Martinian.shopper wrote: > > If not, is there any hope of something like > > the db-api for coarse grained parallelism (i.e, a common API that > > different toolkits can support)? >

How do you pass compiler option to setup.py install?

2008-01-03 Thread Emin.shopper Martinian.shopper
Dear Experts, How do you pass the -c option to setup.py install? Specifically, when I try to install zope.interfaces version 3.3 from source on a windows machine, I get a message about using "-c mingw32". That works fine for setup.py build, but it does not work for "setup.py install". Note: I wou

Re: How do you pass compiler option to setup.py install?

2008-01-03 Thread Emin.shopper Martinian.shopper
On Jan 3, 2008 11:24 AM, Emin.shopper Martinian.shopper < [EMAIL PROTECTED]> wrote: > How do you pass the -c option to setup.py install? After some fiddling, I figured out that you can put the following two lines in setup.cfg: [build] compiler=mingw32 It would be nice if you coul

choosing random dynamic port number

2008-01-03 Thread Emin.shopper Martinian.shopper
Dear Experts, Is there a good way to choose/assign random dynamic port numbers in python? I had in mind something like the following, but if multiple programs are generating random port numbers, is there a way to check if a given port number is already taken? def GenerateDynamicPortNumber():

subprocess and win32security.ImpersonateLoggedOnUser

2009-06-01 Thread Emin.shopper Martinian.shopper
Dear Experts, I am having some issues with the subprocess module and how it interacts with win32security.ImpersonateLoggedOnUser. Specifically, I use the latter to change users but the new user does not seem to be properly inherited when I spawn further subprocesses. I am doing something like

Re: subprocess and win32security.ImpersonateLoggedOnUser

2009-06-01 Thread Emin.shopper Martinian.shopper
Thanks. But how do I fix this so that the subprocess does inherit the impersonated stuff? On Mon, Jun 1, 2009 at 9:38 AM, Tim Golden wrote: > Emin.shopper Martinian.shopper wrote: >> >> Dear Experts, >> >> I am having some issues with the subprocess module a

Re: subprocess and win32security.ImpersonateLoggedOnUser

2009-06-01 Thread Emin.shopper Martinian.shopper
> The source for subprocess just uses CreateProcess. Which means that, > short of monkey-patching it, you're going to have to roll your own > subprocess-like code (I think). Basically, you'll need to run > CreateProcessAsUser or CreateProcessAsLogonW. They're both a bit > of a pig in terms of getti

ANN: superpy 1.2.1

2009-11-09 Thread Emin.shopper Martinian.shopper
I am pleased to announce the release of superpy 1.2.1 available from http://code.google.com/p/superpy. As this is the first announcement of superpy, any comments and feedback would be much appreciated. -- Superpy distributes python programs across a cluster of machines or across

getting MemoryError with dicts; suspect memory fragmentation

2010-06-03 Thread Emin.shopper Martinian.shopper
Dear Experts, I am getting a MemoryError when creating a dict in a long running process and suspect this is due to memory fragmentation. Any suggestions would be welcome. Full details of the problem are below. I have a long running processing which eventually dies to a MemoryError exception. When

Re: getting MemoryError with dicts; suspect memory fragmentation

2010-06-03 Thread Emin.shopper Martinian.shopper
On Thu, Jun 3, 2010 at 7:41 PM, dmtr wrote: > On Jun 3, 3:43 pm, "Emin.shopper Martinian.shopper" > wrote: >> Dear Experts, >> > > Are you sure you have enough memory available? > Dict memory usage can jump x2 during re-balancing. > I'm pretty sur

Re: getting MemoryError with dicts; suspect memory fragmentation

2010-06-04 Thread Emin.shopper Martinian.shopper
On Thu, Jun 3, 2010 at 10:00 PM, dmtr wrote: > I'm still unconvinced that it is a memory fragmentation problem. It's > very rare. You could be right. I'm not an expert on python memory management. But if it isn't memory fragmentation, then why is it that I can create lists which use up 600 more M

Re: getting MemoryError with dicts; suspect memory fragmentation

2010-06-10 Thread Emin.shopper Martinian.shopper
Dear Dmitry, Bryan and Philip, Thanks for the suggestions. I poked around the dictionary descriptions and fiddled some more but couldn't find any obvious error. I agree it does seem odd that a 50 kb dict should fail. Eventually, I tried Dmitry suggestion of moving over to python 2.6. This took a w