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
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
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
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
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
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?
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
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
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
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 =
10 matches
Mail list logo