Best reference that I know of: "Traits: A Mechanism for Fine-grained Reuse" by:
STEPHANE DUCASSE OSCAR NIERSTRASZ and NATHANAEL SCHARLI ROEL WUYTS ANDREW P. BLACK *Inheritance is well-known and accepted as a mechanism for reuse in object-oriented languages. Unfortunately, due to the coarse granularity of inheritance, it may be difficult to decompose an application into an optimal class hierarchy that maximizes software reuse. Existing schemes based on single inheritance, multiple inheritance, or mixins, all pose numerous problems for reuse. To overcome these problems we propose traits, pure units of reuse consisting only of methods. We develop a formal model of traits that establishes how traits can be composed, either to form other traits, or to form classes. We also outline an experimental validation in which we apply traits to refactor a non-trivial application into composable units.* Note that there are several packages already in PyPI: - https://pypi.org/project/traits/ - https://pypi.org/project/strait/ (Never used them myself). S. On Fri, Feb 7, 2020 at 6:04 PM Soni L. <fakedme...@gmail.com> wrote: > > > On 2020-02-07 1:33 p.m., Nick Timkovich wrote: > > On Fri, Feb 7, 2020 at 10:11 AM Soni L. <fakedme...@gmail.com> wrote: > >> I'd like to see traits some day, with a syntax similar to this one: >> ... >> if the trait isn't used in the function definition you get the raw >> object, where name conflicts between traits (but not between traits and >> inherent methods) result in an error about name conflicts. otherwise you >> get a friendly wrapper. >> > > I assume traits are a feature of another language, but not being familiar > with it can you illustrate its need a bit better? Can you give an example > in current Python, and how it could be made more clear with the notional > trait syntax? > > Nick > > > Hello Nick! > > Traits are an alternative to Multiple Inheritance. They solve the problem > of name conflicts by making them an ambiguity error and requiring you to > disambiguate (at call site). > _______________________________________________ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/KFTJ6QRCTICL4NDUURNY35D7JIDM3VWY/ > Code of Conduct: http://python.org/psf/codeofconduct/ > -- Stefane Fermigier - http://fermigier.com/ - http://twitter.com/sfermigier - http://linkedin.com/in/sfermigier Founder & CEO, Abilian - Enterprise Social Software - http://www.abilian.com/ Chairman, National Council for Free & Open Source Software (CNLL) - http://cnll.fr/ Founder & Organiser, PyParis & PyData Paris - http://pyparis.org/ & http://pydata.fr/
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/PQ5Q6LZ6LYTYP6MGLAZ6FS2ZYRFGKXC5/ Code of Conduct: http://python.org/psf/codeofconduct/