In Python, are mixins equivalent to composition? If so, then why not just use composition?
问题 I understand mixin as what looks like inheritance but what is more like composition. (edit: I tend to think giving additional functionality/attributes by mixin rather than giving another is-a relationship .) Mentally, I'm saying something like this when I use mixin: I'm giving you this mixin you are missing, rather than you are actually this mixin-type as well.(is-a) And I read few times, you should prefer composition over inheritance. We could just use straight compositions instead of mixins