On Feb 10, 2008 8:02 PM, Phillip J. Eby &lt;<a href="mailto:pje@telecommunity.com">pje@telecommunity.com</a>&gt; wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
However, since existing code has to be migrated, and lots of things<br>have copy() methods, and 2to3 isn&#39;t going to be able to tell,<br>practicality (IMO) seems to favor keeping the existing method.<br></blockquote></div>
<br>If it only converts dict and set .copy() methods, 2to3 can&#39;t tell, but it wouldn&#39;t be too hard to respell all instances of foo.copy() as copy(foo).&nbsp; Obviously, this is a bit more radical and has good and bad points.&nbsp; It&#39;d be giving every class&#39;s .copy method a promotion to __copy__, basically.<br>
<br>Suggested 2to3 operation:<br><br>foo.copy() =&gt; copy(foo)<br>def copy(self):&nbsp;&nbsp;&nbsp; =&gt;&nbsp; def __copy__(self):&nbsp;&nbsp;&nbsp;&nbsp; (if within a class definition)<br><br>If __copy__(self) is just &quot;self.copy()&quot;, remove it.<br>If copy(self) is just &quot;self.__copy__()&quot; or &quot;copy.copy(self)&quot;, remove it<br>
If a class still defines both __copy__ and copy(), print a warning/error (this should be rare).<br><br>If copy is called with arguments or defined with more than the &quot;self&quot; argument, make no change.<br>If copy is defined with more than the &quot;self&quot; argument, but all the arguments are optional, print a warning/error.<br clear="all">
<br>-- <br>Daniel Stutzbach, Ph.D. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; President, Stutzbach Enterprises LLC