<div class="gmail_quote">On Mon, Jun 1, 2009 at 3:55 PM, Alan Gauld <span dir="ltr">&lt;<a href="mailto:alan.gauld@btinternet.com">alan.gauld@btinternet.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im"><br>
&quot;W W&quot; &lt;<a href="mailto:srilyk@gmail.com" target="_blank">srilyk@gmail.com</a>&gt; wrote<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
class C:<div class="im"><br>
   @constructor<br>
   def LoadFromFile(fname, count): ...<br>
   @constructor<br>
   def Create(valueTuple):...<br>
<br>
Personally I prefer the Delphi style sincve it makes the constructor<br>
call explicit and adds to the documentation.<br>
<br>
Alan G<br>
<br>
</div></blockquote><div class="im">
<br>
That does make it problematic... although I suppose checking the type would<br>
be a workaround - still, not simple or beautiful. Has this been introduced<br>
as a PEP?<br>
</div></blockquote>
<br>
Type checking is the problem. Until Python can distinguish methods based<br>
on types (which introduces other issues)  thisi is difficult with the C/Java style.<br>
<br>
We can fake the Delphi style by using a default constructor and then just<br>
calling the &quot;constructors&quot; after initialisation:<br>
<br>
class C:<br>
        def __init__(): pass<div class="im"><br>
       @constructor<br>
       def LoadFromFile(fname, count): ...<br>
      @constructor<br>
      def Create(valueTuple):...<br>
<br></div>
c = C()<br>
c.LoadFromFile(fn, cnt)<br>
<br>
But its two lines not one... :-(<br>
<br>
And so far as I know it has not been PEPd although I&#39;m sure it has<br>
been discussed.</blockquote><div><br></div><div>I&#39;m not sure how types are implemented in the underlying C, but it seems that it should be a somewhat trivial addition. I mean, type checking is already built-in to python, i.e. type(&#39;a&#39;)  o/p: &lt;type &#39;str&#39;&gt;, so just building a handler specific to the __init__ method, or modifying it if it&#39;s already unique, should be able to take care of it.</div>

<div><br></div><div>I guess one way you could try to parse it on your own is build a list of types: f1 = [type(&#39;&#39;), type(1), type(())], f2 = [type([]), type(1)]]  and compare the types of arguments provided from *args. I suppose really, one could go so far as to build a dict of lists with the lengths:</div>

<div><br></div><div>spam = {1:[[type(&#39;&#39;))],], 2:[[type([]), type(())], [type(1), type(1.0)]</div><div><br></div><div>then compare then lengths of args first.</div><div><br></div><div>That&#39;s a lot of work, though :P</div>

<div>-Wayne</div></div>