Re: deepcopy chokes with TypeError on dynamically assigned instance method

2005-02-15 Thread Kanenas
On Sun, 13 Feb 2005 12:01:42 +1000, Nick Coghlan [EMAIL PROTECTED] wrote: True. It wouldn't cause a problem within my __init__, since the attribute is reassigned after the deepcopy, though should anyone else deepcopy an instance... Definitely better that the deepcopy throws the

Re: deepcopy chokes with TypeError on dynamically assigned instance method

2005-02-12 Thread @t comcast d.t net
On Fri, 11 Feb 2005 21:22:35 +1000, Nick Coghlan [EMAIL PROTECTED] wrote: Interesting. The problem appears to be that bound methods are not copyable: Curiosity got the better of me and I started diggin about in copy.py. Turns out that return values of reductors for functions don't include a

Re: deepcopy chokes with TypeError on dynamically assigned instance method

2005-02-12 Thread Nick Coghlan
@t comcast d.t net @bag.python.org wrote: As an aside, what is the tuple returned by a reductor called? What are its components called? Ya got me. Alex might have a name for it :) Normally, the methods live in the class dictionary, so they don't cause a problem with copying the instance. But

deepcopy chokes with TypeError on dynamically assigned instance method

2005-02-10 Thread 5ÛHH575-UAZWKVVP-7H2H48V3
(see end of message for example code) When an instance has a dynamically assigned instance method, deepcopy throws a TypeError with the message TypeError: instancemethod expected at least 2 arguments, got 0. Tested with Python 2.3.4 on OpenBSD and Python 2.4 on Win98; same results. Is this a

Re: deepcopy chokes with TypeError on dynamically assigned instance method

2005-02-10 Thread Nick Coghlan
5ÛHH575-UAZWKVVP-7H2H48V3 wrote: class Foo(list): Foo def __init__(self, l=[]): Change this too: def __init__(self, l=None): if l is None: l = [] And see if your problem goes away. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia

Re: deepcopy chokes with TypeError on dynamically assigned instance method

2005-02-10 Thread Kanenas
On Thu, 10 Feb 2005 23:50:09 +1000, Nick Coghlan [EMAIL PROTECTED] wrote: def __init__(self, l=[]): Change this too: def __init__(self, l=None): if l is None: l = [] Same error. The only ways of not getting the TypeError I've found are not to call deepcopy or not assign an

Re: deepcopy chokes with TypeError on dynamically assigned instance method

2005-02-10 Thread Kanenas
On Thu, 10 Feb 2005 00:54:04 -0800, Kanenas kanenas @t comcast d.t net wrote: When an instance has a dynamically assigned instance method, deepcopy throws a TypeError with the message TypeError: instancemethod expected at least 2 arguments, got 0. I forgot to mention that the TypeError is