PEP 3133 -- Introducing Roles

I was looking if there was a way not to use method and property inheritance in python, as happens in Perl (Moose framework) with roles. I found this PEP but I didn’t find the real reason for its “rejected”. I tried to follow the guidelines of this project to create a module dedicated to roles, and this is the result: GitHub - MatteoGuadrini/pyrrole: Role system for Python3

I must say that it can be an alternative to the classic editing done with MRO. Can anyone tell me the reason why it was discarded?

There’s a rejection notice at the top of the PEP:

The competitor PEP, PEP 3119, was accepted instead.
Commit: Accepting PEP 3119, rejecting its competitor PEP 3133. · python/peps@a2f9ba6 · GitHub

Another approach can be found in the zope.interface package. You might want to check that out if you’re not familiar with it.


As for why roles weren’t considered necessary given ABCs: the ‘register’ mechanism provides the equivalent of dynamic role assignment, and keeping the existing “isinstance” and “issubclass” query mechanisms was considered preferable to requiring a new way of checking for desired functionality.