[Tutor] Challenge supporting custom deepcopy with inheritance
alan.gauld at btinternet.com
Mon Jun 1 22:55:38 CEST 2009
"W W" <srilyk at gmail.com> wrote
>> class C:
>> def LoadFromFile(fname, count): ...
>> 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 suppose checking the type
> be a workaround - still, not simple or beautiful. Has this been
> as a PEP?
Type checking is the problem. Until Python can distinguish methods based
on types (which introduces other issues) thisi is difficult with the
We can fake the Delphi style by using a default constructor and then just
calling the "constructors" after initialisation:
def __init__(): pass
def LoadFromFile(fname, count): ...
c = C()
But its two lines not one... :-(
And so far as I know it has not been PEPd although I'm sure it has
Author of the Learn to Program web site
More information about the Tutor