On Feb 10, 2008 8:02 PM, Phillip J. Eby <[EMAIL PROTECTED]> wrote: > However, since existing code has to be migrated, and lots of things > have copy() methods, and 2to3 isn't going to be able to tell, > practicality (IMO) seems to favor keeping the existing method. >
If it only converts dict and set .copy() methods, 2to3 can't tell, but it wouldn't be too hard to respell all instances of foo.copy() as copy(foo). Obviously, this is a bit more radical and has good and bad points. It'd be giving every class's .copy method a promotion to __copy__, basically. Suggested 2to3 operation: foo.copy() => copy(foo) def copy(self): => def __copy__(self): (if within a class definition) If __copy__(self) is just "self.copy()", remove it. If copy(self) is just "self.__copy__()" or "copy.copy(self)", remove it If a class still defines both __copy__ and copy(), print a warning/error (this should be rare). If copy is called with arguments or defined with more than the "self" argument, make no change. If copy is defined with more than the "self" argument, but all the arguments are optional, print a warning/error. -- Daniel Stutzbach, Ph.D. President, Stutzbach Enterprises LLC
_______________________________________________ Python-3000 mailing list [email protected] http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com
