Re: type(d) != type(d.copy()) when type(d).issubclass(dict)

2010-12-27 Thread Duncan Booth
kj no.em...@please.post wrote: In (almost?) all cases any objects constructed by a subclass of a builtin class will be of the original builtin class. What I *really* would like to know is: how do *you* know this (and the same question goes for the other responders who see this behavior of

Re: type(d) != type(d.copy()) when type(d).issubclass(dict)

2010-12-26 Thread kj
John O'Hagan resea...@johnohagan.com writes: IMO one of the benefits of subclassing is that you can just bolt on additional behaviour without having to know all the inner workings of the superclass, a benefit that is somewhat defeated by this behaviour of builtins. I agree. I've read the

Re: type(d) != type(d.copy()) when type(d).issubclass(dict)

2010-12-26 Thread kj
In xns9e59a27def178duncanbo...@127.0.0.1 Duncan Booth duncan.bo...@invalid.invalid writes: kj no.em...@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

Re: type(d) != type(d.copy()) when type(d).issubclass(dict)

2010-12-25 Thread Duncan Booth
kj no.em...@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? Feature. In (almost?) all cases any objects constructed by a subclass of

Re: type(d) != type(d.copy()) when type(d).issubclass(dict)

2010-12-25 Thread Steven D'Aprano
On Sat, 25 Dec 2010 15:58:35 +, Duncan Booth wrote: kj no.em...@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? Feature. I'd

Re: type(d) != type(d.copy()) when type(d).issubclass(dict)

2010-12-25 Thread John O'Hagan
On Sat, 25 Dec 2010, Steven D'Aprano wrote: On Sat, 25 Dec 2010 15:58:35 +, Duncan Booth wrote: kj no.em...@please.post wrote: Watch this: class neodict(dict): pass ... d = neodict() type(d) class '__main__.neodict' type(d.copy()) type 'dict' Bug? Feature?

type(d) != type(d.copy()) when type(d).issubclass(dict)

2010-12-24 Thread kj
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? ~kj -- http://mail.python.org/mailman/listinfo/python-list

Re: type(d) != type(d.copy()) when type(d).issubclass(dict)

2010-12-24 Thread David Robinow
On Fri, Dec 24, 2010 at 1:52 PM, kj no.em...@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

Re: type(d) != type(d.copy()) when type(d).issubclass(dict)

2010-12-24 Thread Flávio Lisbôa
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) One more gotcha to python... OO in python is

Re: type(d) != type(d.copy()) when type(d).issubclass(dict)

2010-12-24 Thread Benjamin Kaplan
On Dec 24, 2010 4:40 PM, Flávio Lisbôa flisboa.co...@gmail.com wrote: 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 =