Re: Problem using copy.copy with my own class

2008-04-24 Thread Jeffrey Barish
George Sakkis wrote: > First off, inheriting from a basic builtin type such as int and > changing its constructor's signature is not typical; you should > rethink your design unless you know what you're doing. Nah, I would never claim to know what I'm doing. However, I have to say that I have be

Re: Problem using copy.copy with my own class

2008-04-23 Thread George Sakkis
On Apr 23, 9:48 pm, Jeffrey Barish <[EMAIL PROTECTED]> wrote: > > Here it is: > > import copy > > class Test(int): >     def __new__(cls, arg1, arg2): >         return int.__new__(cls, arg1) > >     def __init__(self, arg1, arg2): >         self.arg2 = arg2 > > if __name__ == '__main__': >     t =

Re: Problem using copy.copy with my own class

2008-04-23 Thread Gabriel Genellina
En Thu, 24 Apr 2008 01:21:15 -0300, Gabriel Genellina <[EMAIL PROTECTED]> escribió: I agree. In case arg2 were really meaningful, use __getnewargs__ (see ) I forget to include the link: -- Gabriel Genellina -- http://mail.python.org/mailman/lis

Re: Problem using copy.copy with my own class

2008-04-23 Thread Gabriel Genellina
En Thu, 24 Apr 2008 00:32:37 -0300, Michael Torrie <[EMAIL PROTECTED]> escribió: Jeffrey Barish wrote: Marc 'BlackJack' Rintsch wrote: Please simplify the code to a minimal example that still has the problem and *show it to us*. It's hard to spot errors in code that nobody except you kn

Re: Problem using copy.copy with my own class

2008-04-23 Thread Michael Torrie
Jeffrey Barish wrote: > Marc 'BlackJack' Rintsch wrote: >> Please simplify the code to a minimal example that still has the problem >> and *show it to us*. It's hard to spot errors in code that nobody except >> you knows. > > Here it is: > > import copy > > class Test(int): > def __new__(cl

Re: Problem using copy.copy with my own class

2008-04-23 Thread Jeffrey Barish
Marc 'BlackJack' Rintsch wrote: > Please simplify the code to a minimal example that still has the problem > and *show it to us*. It's hard to spot errors in code that nobody except > you knows. Here it is: import copy class Test(int): def __new__(cls, arg1, arg2): return int.__new_

Re: Problem using copy.copy with my own class

2008-04-22 Thread Marc 'BlackJack' Rintsch
On Tue, 22 Apr 2008 11:13:43 -0600, Jeffrey Barish wrote: > By the way, I have simplified somewhat the code in the explanation. Please simplify the code to a minimal example that still has the problem and *show it to us*. It's hard to spot errors in code that nobody except you knows. -- http://m

Problem using copy.copy with my own class

2008-04-22 Thread Jeffrey Barish
(Pdb) myclass MyClass( 0, 0, 'A string', 123.45) (Pdb) copy.copy(myclass) *** TypeError: TypeError('__new__() takes at least 4 arguments (2 given)',) I see 4 arguments (actually, 5 because Python is passing cls invisibly to __new__). Does anyone have an idea what is going on here? I have not def