type(d) != type(d.copy()) when type(d).issubclass(dict)
David Robinow
drobinow at gmail.com
Fri Dec 24 16:17:40 EST 2010
On Fri, Dec 24, 2010 at 1:52 PM, kj <no.email at please.post> wrote:
> Watch this:
>
>>>> class neodict(dict): pass
> ...
>>>> d = neodict()
>>>> type(d)
> <class '__main__.neodict'>
>>>> type(d.copy())
> <type 'dict'>
>
>
> Bug? Feature? Genius beyond the grasp of schlubs like me?
copy, here, is a dict method. It will create a dict.
If you really need it, you could try this:
import copy
class neodict(dict):
def copy(self):
return copy.copy(self)
d = neodict()
print type(d)
dd = d.copy()
print type(dd)
More information about the Python-list
mailing list