Disable automatic interning
andrew at acooke.org
Wed Mar 18 21:50:48 CET 2009
George Sakkis wrote:
> I'm working on some graph generation problem where the node identity
> is significant (e.g. "if node1 is node2: # do something) but ideally I
> wouldn't want to impose any constraint on what a node is (i.e. require
> a base Node class). It's not a show stopper, but it would be
> problematic if something broke when nodes happen to be (small)
> integers or strings.
this is completely normal (i do exactly this all the time), BUT you should
use "==", not "is". then you can define your own equality by providing
the __eq__ method (sometimes it can be very useful for nodes to be
considered equal even when they are separate instances - for example in
generating cyclic graphs).
More information about the Python-list