Python declarative

Chris Angelico rosuav at gmail.com
Fri Jan 24 11:33:27 EST 2014


On Sat, Jan 25, 2014 at 3:28 AM, Matěj Cepl <mcepl at redhat.com> wrote:
> On 2014-01-24, 11:18 GMT, you wrote:
>> Write your rendering engine as a few simple helper functions,
>> and then put all the rest in as code instead of XML. The
>> easiest way to go about it is to write three forms, from
>> scratch, and then look at the common parts and figure out
>> which bits can go into helper functions.
>
> Perhaps what's missing is full acknowledgment that Python has
> dual-inheritance and thus it can have mixin classes (which seems
> to me to be the only useful use of dual inheritance). You know
> you can have mixins in Python, right?

Hmm, I've never really felt the need to work that way. Usually it's
functions I want, not classes; but if they're classes, then generally
they're just to add a couple of methods, or change the construction
args, so single inheritance is plenty. (I created a
MultiLineEntryField class as a thin wrapper around TextView, adding
get_text() and set_text() with the same signatures as GTK2.Entry()'s
methods of the same names. That wouldn't apply to anything else, so a
mixin wouldn't help much.) But sure. If you want mixins, go for it.

ChrisA



More information about the Python-list mailing list