On Feb 11, 10:56 am, Ian Kelly wrote:
> On Sat, Feb 11, 2012 at 10:54 AM, Ian Kelly wrote:
> > class Dog(dict):
>
> > def __missing__(self):
> > return 0
>
> Sorry, that should have been:
>
> class Dog(dict):
>
> def __missing__(self, key):
> return 0
>
> Cheers,
> Ian
Than
On Sat, Feb 11, 2012 at 10:54 AM, Ian Kelly wrote:
> class Dog(dict):
>
> def __missing__(self):
> return 0
Sorry, that should have been:
class Dog(dict):
def __missing__(self, key):
return 0
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
On Sat, Feb 11, 2012 at 10:46 AM, Ian Kelly wrote:
> The problem is that defaultdict defines a custom __reduce__ method
> which is used by the pickle protocol to determine how the object
> should be reconstructed. It uses this to reconstruct the defaultdict
> with the same default factory, by cal
On Fri, Feb 10, 2012 at 7:48 PM, 7stud <7s...@excite.com> wrote:
> But I cannot get a class that inherits from collections.defaultdict to
> shelve itself:
>
>
> import collections as c
> import shelve
>
> class Dog(c.defaultdict):
> def __init__(self):
> super().__init__(int, Joe=0)
>
On Feb 10, 7:52 pm, 7stud <7s...@excite.com> wrote:
I don't know if this helps, but I notice when I initially do this:
shelve.open('data22')
the file is saved as 'data22.db'. But on subsequent calls to
shelve.open(), if I use the file name 'data22.db', I get a different
error:
--output:--
**
On Feb 10, 7:48 pm, 7stud <7s...@excite.com> wrote:
>
> But I cannot get a class that inherits from collections.defaultdict to
> shelve itself:
>
> import collections as c
> import shelve
>
> class Dog(c.defaultdict):
> def __init__(self):
> super().__init__(int, Joe=0)
> print(