Michael Spencer wrote:
> It appears that if you want to deepcopy an object that may contain
arrays,
> you're going to have to 'roll your own' deep copier. Something like
this
> would do it:
[method deleted]
Whew! Michael, that was way more than I bargained for. New issues for
me: the "**" nota
Michael Spencer wrote:
> [EMAIL PROTECTED] wrote:
> > I'm back...
> [wondering why copy.deepcopy barfs on array instances]
> >
>
> http://www.python.org/doc/2.3.3/lib/module-copy.html
> deepcopy:
> ...
> This version does not copy types like module, class, function,
method, stack
> trace, stack fra
Michael Spencer wrote:
http://www.python.org/doc/2.3.3/lib/module-copy.html
deepcopy:
...
This version does not copy types like module, class, function, method,
stack trace, stack frame, file, socket, window, *array*, or any similar
types.
...
On reflection, I realize that this says that the arr
[EMAIL PROTECTED] wrote:
I'm back...
[wondering why copy.deepcopy barfs on array instances]
http://www.python.org/doc/2.3.3/lib/module-copy.html
deepcopy:
...
This version does not copy types like module, class, function, method, stack
trace, stack frame, file, socket, window, *array*, or any sim
I'm back...
Thanks to Michael Spencer and Steven Bethard for their excellent help.
It has taken me a few sessions of reading, and programming, and I've
had to pick up the exploded fragments of my skull from time to time.
But I now have succeeded in making deepcopy work for a simple class
that I wr
Michael Spencer wrote:
BTW, as I mentioned in a previous comment, I believe this would be more
plainly written as type(self).__new__(), to emphasize that you are
constructing the object without initializing it. (There is a
explanation of __new__'s behaviour at
http://www.python.org/2.2/descrin
[EMAIL PROTECTED] wrote:
...
I see Steve Bethard has answered most of the points in your last eMail
On line 11 we create a
dictionary item in memo, [id(self):type(self)]...So now I'm confused as
to the purpose of memo. Why should it contain the ID of the *original*
object?
No, you create memo[id(s
[EMAIL PROTECTED] wrote:
Michael Spencer wrote:
[EMAIL PROTECTED] wrote:
[snip]
Anyway, my present problem is that I want to make copies of
instances
of my own custom classes. I'm having a little trouble
understanding
the process. Not that I think that it matters -- but in case it
does,
I'll tell
Michael Spencer wrote:
> [EMAIL PROTECTED] wrote:
[snip]
> > Anyway, my present problem is that I want to make copies of
instances
> > of my own custom classes. I'm having a little trouble
understanding
> > the process. Not that I think that it matters -- but in case it
does,
> > I'll tell you th
Steven Bethard wrote:
Michael Spencer wrote:
def __deepcopy__(self, memo={}):
from copy import deepcopy
result = self.__class__()
memo[id(self)] = result
result.__init__(deepcopy(tuple(self), memo))
return result
I know this is not your recipe, but is th
Michael Spencer wrote:
def __deepcopy__(self, memo={}):
from copy import deepcopy
result = self.__class__()
memo[id(self)] = result
result.__init__(deepcopy(tuple(self), memo))
return result
I know this is not your recipe, but is there any reason to use
[EMAIL PROTECTED] wrote:
Hi, folks,
First, the obligatory cheerleading -- then, my questions...
I love Python! I am only an occasional programmer. Still, the logic
of the language is clear enough that I can retain pretty much all that
I have learned from one infrequent programming session to the
Hi, folks,
First, the obligatory cheerleading -- then, my questions...
I love Python! I am only an occasional programmer. Still, the logic
of the language is clear enough that I can retain pretty much all that
I have learned from one infrequent programming session to the next.
That's quite an a
13 matches
Mail list logo