This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author trcarden
Recipients r.david.murray, trcarden
Date 2015-05-14.00:34:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1431563662.24.0.827126550893.issue24183@psf.upfronthosting.co.za>
In-reply-to
Content
Hmm Ok. You are right i can do the following:

from collections import UserDict
from abc import ABCMeta


class MetaMyDict(ABCMeta):

    @classmethod
    def __prepare__(cls, name, bases, **kwargs):
        return {}

    def __new__(mcls, name, bases, namespace, **kwds):
        return super().__new__(mcls, name, bases, namespace)

    def __init__(cls, name, bases, namespace, **kargs):
        return super().__init__(name, bases, namespace)

class MyDict(UserDict, metaclass=MetaMyDict, bar='baz'):
    pass

dictionary = MyDict()

But I guess i would have expected a core lib library to be consistent with the data model https://docs.python.org/3.4/reference/datamodel.html#preparing-the-class-namespace. As it stands an end user can't get a subclass of ABCMeta to work with the same **kwargs interface without creating a custom metaclass that strips it out before passing to ABCMeta. 

Wouldn't it be much easier and technically correct for the core ABCMeta library to adopt the same interface contract for class creation introduced in python3?
History
Date User Action Args
2015-05-14 00:34:22trcardensetrecipients: + trcarden, r.david.murray
2015-05-14 00:34:22trcardensetmessageid: <1431563662.24.0.827126550893.issue24183@psf.upfronthosting.co.za>
2015-05-14 00:34:22trcardenlinkissue24183 messages
2015-05-14 00:34:20trcardencreate