Re: __slots__ and copy again: why does it work?

2005-12-26 Thread fortepianissimo
To be complete, the first code snippet, when modified as follows, works fine in Python 2.4.2: --- START --- #!/usr/bin/env python import copy class Foo (object): __slots__ = ('i', ) def __init__ (self): self.i = 10 class Bar (Foo): __slots__ = ('j', ) def __init__ (self): supe

Re: __slots__ and copy again: why does it work?

2005-12-26 Thread limodou
26 Dec 2005 20:33:35 -0800, fortepianissimo <[EMAIL PROTECTED]>: > Mystery solved - when there's only one slot I should've used __slots__ > = ('i', ). Duh! > > So in short, __slots__ and copy.copy() work fine in Python 2.4.2. > Hard works, but very useful :) -- I like python! My Blog: http://www.

Re: __slots__ and copy again: why does it work?

2005-12-26 Thread fortepianissimo
Mystery solved - when there's only one slot I should've used __slots__ = ('i', ). Duh! So in short, __slots__ and copy.copy() work fine in Python 2.4.2. -- http://mail.python.org/mailman/listinfo/python-list

Re: __slots__ and copy again: why does it work?

2005-12-26 Thread fortepianissimo
More weird observations: the following code does not work until you change the name of the member 'longer' to a one-char name, for example, 'j': --- START --- #!/usr/bin/env python import copy class Foo (object): __slots__ = 'i' class Bar (Foo): __slots__ = 'longer' #__slots__ = 'j'

Re: __slots__ and copy again: why does it work?

2005-12-26 Thread fortepianissimo
I should've mentioned this was tested on Python 2.4.2. fortepianissimo wrote: > I remember from painful experience that copy.copy() won't really copy > __slots__ members. But I have trouble explaning why the following code > works: > > --- START--- > #!/usr/bin/env python > > import copy > > > cl

__slots__ and copy again: why does it work?

2005-12-26 Thread fortepianissimo
I remember from painful experience that copy.copy() won't really copy __slots__ members. But I have trouble explaning why the following code works: --- START--- #!/usr/bin/env python import copy class Foo (object): __slots__ = 'i' def __init__ (self): self.i = 10 class Bar (Foo): _