Volker Braun wrote:
> The many ways of implementing xor...
>
> Incidentally, if there is some global switch to return certificates
> instead of booleans then the sum version is the correct one ;-)
Besides the perhaps clumsy syntax in Python, it's IMHO ok. Just imagine
we had a list of more than two graphs; actually 'sum(l)==1' should be
'sum(l) not in (0, len(l))'.
Of course there are nicer versions with map(), filter(), any() or all()
etc. (sum() is of course also just an application of reduce(), just
like any() and all() are, but the latter do not necessarily have to
evaluate each list element, so can be faster in the average case.)
-leif
P.S.: Wouldn't it make more sense to raise a TypeError? After all,
directed and undirected graphs are different structures.