En Sat, 26 Sep 2009 01:48:08 -0300, Steven D'Aprano <st...@remove-this-cybersource.com.au> escribió:

I'm aiming for some sort of polymorphic inheritance: in a method, if the
argument meets some condition, inherit from PClass, if it meets another
condition inherit from NClass, and so on. Is there are standard name for
this idea?

That doesn't look like an inheritance relationship ("is a").
If you say "from now on, act as a PClass, until further notice" and later "now, act as a NClass" you're using the Strategy pattern.

If you decide at every invocation which method to call, it's a dispatcher; you may use a dictionary to map each alternative to the function to be invoked. If it only depends on the type of the argument, there is a hidden gem in pkgutil (simplegeneric) that can help you.

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to