problems with shelve(), collections.defaultdict, self

7stud 7stud at excite.com
Sat Feb 11 03:52:08 CET 2012


On Feb 10, 7:48 pm, 7stud <7s... at 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('****', self)

Whoops.  I changed:

    super().__init__(int, Joe=0)

to:

    super().__init__(int, Joe=30)

hence this output..

    > --output:--
    >
    > **** defaultdict(<class 'int'>, {'Joe': 30})



More information about the Python-list mailing list