'Evaluate commutator'

def doit(self, **hints):

    A = self.args[0]
    B = self.args[1]
    if (isinstance(A, Operator) and isinstance(B, Operator)):
        try:
            comm = A._eval_commutator(B, **hints)
        except NotImplementedError:
            try:
                comm = ((-1) * B._eval_commutator(A, **hints))
            except NotImplementedError:
                comm = None
        if (comm is not None):
            return comm.doit(**hints)
    return ((A * B) - (B * A)).doit(**hints)
