how to dispatch objects depending on their class

Curzio Basso curzio.basso at unibas.ch
Wed Aug 11 04:12:33 EDT 2004


Casey Duncan wrote:

> It should not be a problem to use the actual class object as keys in the
> dict and the functions as values. No need to convert the class to
> strings.

Ops, did not think about that. But maybe the string is a more efficient key?

> So why can't they be static methods of the classes exactly? That would
> be simpler, however the dict will work efficiently.

Well, as I wrote in the original post and in some reply, I want to keep 
the logic of this particular function separated from the class 
hierarchy. And as cmedcoff at hotmail.com suggested this could be a Visitor 
pattern. I'm looking on that.

cheers, curzio



More information about the Python-list mailing list