bug in copy.deepcopy or in getattr or in my understanding?

2007-01-04 Thread Emin
Dear experts, I got some unexpected behavior in getattr and copy.deepcopy (see transcript below). I'm not sure if this is actually a bug in copy.deepcopy or if I'm doing something too magical with getattr. Comments would be appreciated. Thanks, -Emin # Transcri

Re: bug in copy.deepcopy or in getattr or in my understanding?

2007-01-05 Thread Emin
w__(cls, *args) TypeError: instancemethod expected at least 2 arguments, got 0 >>> >>> # The following shows that getattr is doing something different >>> # than looking in the __dict__ of base classes >>> b.__bases__[0].__dict__['foo'] >>> getattr

what is the idiom for copy lots of params into self?

2007-01-10 Thread Emin
[name] This saves a lot of code and makes it easier to see what is going on, but it seems like there should be a better idiom for this task. Any suggestions? Thanks, -Emin -- http://mail.python.org/mailman/listinfo/python-list

Re: what is the idiom for copy lots of params into self?

2007-01-11 Thread Emin
, but whether it's okay to mess with self.__dict__ or if there is another way I should be assigning to self. Thanks, -Emin On Jan 10, 9:05 pm, "Luis M. González" <[EMAIL PROTECTED]> wrote: > Emin wrote: > > Dear Experts, > > > When writing large classes, I

Re: what is the idiom for copy lots of params into self?

2007-01-11 Thread Emin
Thanks, that looks like what I wanted. On Jan 11, 8:36 am, "Fredrik Lundh" <[EMAIL PROTECTED]> wrote: > "Emin" <[EMAIL PROTECTED]> wrote: > > What made me ask the question in my original post was not so much that > > I had to loop over the names I wa

How much slower is dict indexing vs. list indexing?

2007-01-11 Thread Emin
work to compute and store an index into a list to avoid repeated hash table lookups. From my tests, it looks like the answer is basically "don't bother". Does anyone have information, thoughts, or comments on this? Thanks, -Emin -- http://mail.python.org/mailman/listinfo/python-list

Re: How much slower is dict indexing vs. list indexing?

2007-01-12 Thread Emin
On Jan 11, 5:53 pm, Steve Holden <[EMAIL PROTECTED]> wrote: > > What technique were you thinking of to look up the cached index values > in Python, just as a matter of curiosity? Storing them in a dict? It > would be hard to think of a faster way ... ;-) I didn't have anything fancy in mind. I was

question about module resolution

2007-01-17 Thread Emin
Dear Experts, I often find myself wanting to have a child module get some parameters defined in a parent module. For example, imagine I have the following directory structure and want something in baz.py to look at a value in config.py. I end up putting in things like import sys; sys.path.append(

Re: question about module resolution

2007-01-17 Thread Emin
recent call last): File "", line 1, in File "baz.py", line 3, in from .. import config ValueError: Attempted relative import in non-package On Jan 17, 11:20 am, Peter Otten <[EMAIL PROTECTED]> wrote: > Emin wrote: > > I often find myself wanting to have a c

emacs shell hangs on W32 with python

2006-11-02 Thread emin . shopper
lem. I also reproduced the problem with GNU Emacs (version "GNU Emacs 21.3.1 (i386-mingw-nt5.1.2600) of 2004-03-10 on NYAUMO") Is there any way to run python through emacs or xemacs without having it hang or is shell support broken? Thanks in advance, -Emin -- http://mail.python.org/mailman/listinfo/python-list

Re: emacs shell hangs on W32 with python

2006-11-03 Thread emin . shopper
Hmm, it doesn't even work if I run the cygwin version of GNU Emacs and have it start the Windows version of python through python-mode or if I start a shell in emacs and then start the Windows version of python through the shell. Interestingly, however, things DO seem to work if I use cygwin emacs

Re: emacs shell hangs on W32 with python

2006-11-03 Thread emin . shopper
The same problems occur with the latest emacs binary from CVS (emacs-version) "GNU Emacs 23.0.0.1 (i386-mingw-nt5.1.2600) of 2006-10-16 on DTOP" Lennart Borgman wrote: > Would it not be a good idea to try the CVS version of Emacs for this now > since the pretest will soon begin? Go here for preco

Re: emacs shell hangs on W32 with python

2006-11-03 Thread emin . shopper
, python keeps accepting input). Consequently, it seems like emacs is doing something funky when running the shell that interferes with python in a way that running the shell without emacs would not do. Sincerely, -Emin Martinian In GNU Emacs 23.0.0.1 (i386-mingw-nt5.1.2600) of 2006-10-16 on DTOP

"initializer element is not constant"

2006-05-30 Thread emin . martinian
When trying to compile python extensions written in C using "python setup.py build" on cygwin I get the following error: foo.c: initializer element is not constant foo.c: error: (near initialization for `FooType.ob_type') I remember someone telling me a long time ago that this had something to do

Re: I'm looking for a pythonic red-black tree...

2006-12-15 Thread emin . shopper
You could try and wrap the C/C++ code at http://web.mit.edu/~emin/www/source_code/index.html and make a python extension... On Dec 14, 8:20 pm, "Just Another Victim of the Ambient Morality" <[EMAIL PROTECTED]> wrote: > I need a red-black tree in Python and I was wonderi

module to implement Abstract Base Class

2006-12-22 Thread emin . shopper
catch mistakes at definition time (e.g., forgetting to implement a method required by the given interface). This is handy when unit tests or running the actual program take a while. Comments and suggestions are welcome. Thanks, -Emin ### Abstract Base Class Module Follows