[Tutor] class wrapper question (from Dive into Python)
John Abbe
johnca@ourpla.net
Wed Mar 12 05:46:58 2003
I'm going through <http://www.diveintopython.org/>, and highly
recommend it to all the other newbies out there. I'm halfway through
chapter 3 before a serious question occurred to me. This, like not
noticing the technology in computer animation movies, is a good thing.
Okay...
From <http://www.diveintopython.org/fileinfo_specialmethods.html>,
the old UserDict class:
> def clear(self): self.data.clear() 1
> def copy(self): 2
> if self.__class__ is UserDict: 3
> return UserDict(self.data)
> import copy 4
> return copy.copy(self)
> def keys(self): return self.data.keys() 5
> def items(self): return self.data.items()
> def values(self): return self.data.values()
My question is, in copy, why bother with checking if it's a
UserDict...why isn't it just like this?
def copy(self):
import copy
return copy.copy(self)
Life,
John
--
------===>> AbbeNormal <<===------ | ..:::..
A wiki-weblog, somewhere under the | .:::::::*:::.
multi-dimensional normal curve | ..:::::::::::::::..
http://ourpla.net/cgi/pikie |....::::::::::*:::::::::::*....