Re: [Tutor] Challenge supporting custom deepcopy with inheritance

2009-06-01 Thread Alan Gauld
"Kent Johnson" wrote > We can fake the Delphi style by using a default constructor and then > just > calling the "constructors" after initialisation: > But its two lines not one... :-( Why not this? class C: def __init__(self): pass @staticmethod def LoadFromFile(fname, count): c

Re: [Tutor] Challenge supporting custom deepcopy with inheritance

2009-06-01 Thread Alan Gauld
"Kent Johnson" wrote But its two lines not one... :-( Why not this? class C: def __init__(self): pass @staticmethod def LoadFromFile(fname, count): c = C() # init c from the file return c and similar for Create(). Client code is one line: c = C.LoadFromFile(fn, cnt) Kent

Re: [Tutor] Challenge supporting custom deepcopy with inheritance

2009-06-01 Thread W W
On Mon, Jun 1, 2009 at 3:55 PM, Alan Gauld wrote: > > "W W" wrote > >> class C: >>> @constructor >>> def LoadFromFile(fname, count): ... >>> @constructor >>> def Create(valueTuple):... >>> >>> Personally I prefer the Delphi style sincve it makes the constructor >>> call explicit and adds

Re: [Tutor] Challenge supporting custom deepcopy with inheritance

2009-06-01 Thread Kent Johnson
On Mon, Jun 1, 2009 at 4:55 PM, Alan Gauld wrote: > We can fake the Delphi style by using a default constructor and then just > calling the "constructors" after initialisation: > > class C: >        def __init__(): pass >       @constructor >       def LoadFromFile(fname, count): ... >     �...@c

Re: [Tutor] Challenge supporting custom deepcopy with inheritance

2009-06-01 Thread Alan Gauld
"W W" wrote class C: @constructor def LoadFromFile(fname, count): ... @constructor def Create(valueTuple):... Personally I prefer the Delphi style sincve it makes the constructor call explicit and adds to the documentation. Alan G That does make it problematic... although I sup

Re: [Tutor] Challenge supporting custom deepcopy with inheritance

2009-06-01 Thread W W
On Mon, Jun 1, 2009 at 8:59 AM, Alan Gauld wrote: > > "W W" wrote > > ( Multiple constructors (or factory methods) is one feature I would like >>> to see added to Python! ) >>> >> >> Wouldn't it be possible to create sort of a... bastardization? i.e. >> >> def __init__(self, *args): >> if len

Re: [Tutor] Challenge supporting custom deepcopy with inheritance

2009-06-01 Thread Michael H . Goldwasser
Chris, Thanks for your well-written reply. Your analogy to the complexities of other special methods is well noted. I'll accept the "small price for flexibility" that you note, if necessary. However, I still desire a cleaner solution. I can examine the inherited slots to see which sp

Re: [Tutor] Challenge supporting custom deepcopy with inheritance

2009-06-01 Thread Alan Gauld
"W W" wrote ( Multiple constructors (or factory methods) is one feature I would like to see added to Python! ) Wouldn't it be possible to create sort of a... bastardization? i.e. def __init__(self, *args): if len(args) == 0: #do something if len(args) == 1: #do somethin

Re: [Tutor] Challenge supporting custom deepcopy with inheritance

2009-06-01 Thread W W
On Mon, Jun 1, 2009 at 2:27 AM, Alan Gauld wrote: > > "Kent Johnson" wrote > >> > Yesterday, I posted a question to python-list involving custom >> > deepcopies in an inheritance hierarchy. I haven't received any >> >> ISTM that in general B.__deepcopy__() should call A.__deepcopy__() to do >> th

Re: [Tutor] Challenge supporting custom deepcopy with inheritance

2009-06-01 Thread Alan Gauld
"Kent Johnson" wrote > Yesterday, I posted a question to python-list involving custom > deepcopies in an inheritance hierarchy. I haven't received any ISTM that in general B.__deepcopy__() should call A.__deepcopy__() to do the "A" part of the work. In your example, this won't work because

Re: [Tutor] Challenge supporting custom deepcopy with inheritance

2009-05-31 Thread Kent Johnson
On Sun, May 31, 2009 at 5:35 PM, Michael H. Goldwasser wrote: > > Yesterday, I posted a question to python-list involving custom > deepcopies in an inheritance hierarchy.  I haven't received any > responses, so I thought I'd cross-post to see if anyone on tutor > has any thoughts. > > To avoid spl

[Tutor] Challenge supporting custom deepcopy with inheritance

2009-05-31 Thread Michael H . Goldwasser
Yesterday, I posted a question to python-list involving custom deepcopies in an inheritance hierarchy. I haven't received any responses, so I thought I'd cross-post to see if anyone on tutor has any thoughts. To avoid splitting the thread, I'll simply reference the original post at http://mail.p