Skip to content

Delegating dunders, class makers, and pickles #85

Description

@thorwhalen

In grub/base.py:

Since getattr deligation doesn't work with dunders, did this:

class SearchStoreMixin(KvReader):
    store_attr = 'search_store'

    def __getitem__(self, k):
        return getattr(self, self.store_attr).__getitem__(k)

    def __iter__(self):
        return getattr(self, self.store_attr).__iter__()

    def __contains__(self, k):
        return getattr(self, self.store_attr).__contains__(k)

    def __len__(self):
        return getattr(self, self.store_attr).__len__()


class StoreMixin(SearchStoreMixin):
    store_attr = 'store'

But surely, there's a more conciser way to do it.

I can make a function that makes classes, but will it pickle?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions