Daniel Urban <urban.dani...@gmail.com> added the comment: I've attached a patch with more tests. I simply copied and modified the tests about metaclass calculation and __prepare__ in test_descr.py, to create the tested classes with operator.build_class (and not the class statement).
Although, there is one thing I'm not sure I like about the API in the current patch: the dictionary corresponding to the keyword arguments of the class statement cannot be passed as keyword arguments. For example, I can't write this: C = operator.build_class('C', (A, B), metaclass=MyMeta) I have to write this: C = operator.build_class('C', (A, B), {'metaclass': MyMeta}) (The reason for this is that the eval_body argument is the last.) What would you think about the following signature for build_class? build_class(name, bases=(), eval_body=None, **kwargs) The fist 3 argument could be positional only, and all keyword arguments would go into the dict. A downside is that the user would have to explicitly pass None as the 3rd argument, if they don't need an eval_body, but need keyword-arguments. Also, the 'bases' and the keyword arguments wouldn't be close to each other as in the class statement... ---------- Added file: http://bugs.python.org/file25263/operator_build_class_2.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue14588> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com