Timothy Cardenas added the comment:
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?
----------
resolution: not a bug -> remind
status: closed -> open
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue24183>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com