"W W" <sri...@gmail.com> 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 suppose checking the type would be a workaround - still, not simple or beautiful. Has this been introduced
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 C/Java style.

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): ...
      @constructor
      def Create(valueTuple):...

c = C()
c.LoadFromFile(fn, cnt)

But its two lines not one... :-(

And so far as I know it has not been PEPd although I'm sure it has
been discussed.

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to