Re: problems with shelve(), collections.defaultdict, self

2012-02-11 Thread 7stud
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

Re: problems with shelve(), collections.defaultdict, self

2012-02-11 Thread Ian Kelly
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

Re: problems with shelve(), collections.defaultdict, self

2012-02-11 Thread Ian Kelly
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

Re: problems with shelve(), collections.defaultdict, self

2012-02-11 Thread Ian Kelly
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) >    

Re: problems with shelve(), collections.defaultdict, self

2012-02-10 Thread 7stud
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:-- **

Re: problems with shelve(), collections.defaultdict, self

2012-02-10 Thread 7stud
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(