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 been
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
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__(cls, arg1,
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
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: http://docs.python.org/lib/pickle-inst.html
--
Gabriel Genellina
--
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 = Test(0, 0)
(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
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.
--