how to do proper subclassing?

Jonas Koelker jonaskoelker at yahoo.com
Tue Aug 3 18:59:10 CEST 2004


Hello there.

I'm new to this list (/me welcomes himself).

anyways, I'm having doubts about how to subclass
properly. The big picture is that I want to handle
permutations. As we all know, two popular notation
forms exist: products of disjoint cycles ("(0 1 3)(2
4)") and 2*length matrices with the identity
permutation as the first line ([0 1 2 3 4] over [1 3 4
0 2]). I find the latter more appropriate, since it's
easy to store as a list (one can skip the first line,
assuming it's _always_ the identity). 

However, I want the permutation to act like a list, in
all those cases where I don't override the operations.
For example, assuming permfooation is the above
permutation [1 3 4 0 2], permfooation[1:3] should
return [3,4]. How is this done? Do I have to actually
implement a slice-mechanism in the permutation class?

thanks,

-- Jonas Kölker


	
	
		
___________________________________________________________ALL-NEW Yahoo! Messenger - all new features - even more fun!  http://uk.messenger.yahoo.com



More information about the Python-list mailing list