How best to return a class method?

Roy Smith roy at panix.com
Wed Oct 6 10:20:42 EDT 2004


I've got a method which returns another method:

class domPrinter:
    def getNodePrinter (self, nodeType):
	[...]
        # return domPrinter.printUnknown
	return self.__class__.printUnknown

I originally wrote it as the commented-out version, but didn't like
the idea that I've got to repeat the class name.  The version using
self.__class__ solves that problem, but it's uglier and more
complicated.

Any opinions on the best way to do this?



More information about the Python-list mailing list