Returning different types based on input parameters

George Sakkis george.sakkis at gmail.com
Tue Apr 7 00:56:45 CEST 2009


On Apr 6, 5:56 pm, MRAB <goo... at mrabarnett.plus.com> wrote:

> In your example I would possibly suggest returning a 'Result' object and
> then later subclassing to give 'ConfidenceResult' which has the
> additional 'confidence' attribute.

That's indeed one option, but not very appealing if `Result` happens
to be a builtin (e.g. float or list). Technically you can subclass
builtins but I think, in this case at least, the cure is worse than
the disease.

George



More information about the Python-list mailing list