Subclassing list: am I doing it properly?
<p>I want to subclass <code>list</code> into <code>Clause</code> to give it three properties:</p>

<ol>
<li><p>Every element of a <code>Clause</code> is a <code>Lit</code></p></li>
<li><p>Certain operators like <code>|</code> and <code>&amp;</code> are overloaded</p></li>
<li><p>If <code>a</code> and <code>b</code> are of type <code>Clause</code>, then so is <code>a+b</code></p></li>
</ol>

<p>This is what I've got so far, but I'm pretty sure it's wrong... what's the best way to do this?</p>

<pre><code>class Clause(list):
    def __init__(self, raw_list):
        for lit in raw_list:
            if not isinstance(lit, Lit):
                raise TypeError, 'Clause contains non-Lit elements'
        self = raw_list

    def __invert__(self):
        return Formula([Clause([~lit]) for lit in self])

    def __or__(self, right):
        if not isinstance(right, Clause):
            raise TypeError, 'RHS is not of type Clause'
        return Formula([self + right])

    def __and__(self, right):
        if not isinstance(right, Clause):
            raise TypeError, 'RHS is not of type Clause'
        return Formula([self, right])
</code></pre>