stylistic question -- optional return value

Christian Tanzer tanzer at
Thu Aug 29 09:43:50 CEST 2002

Andrew Koenig <ark at> wrote:

> Hans> Still, I believe that rewriting the function (or splitting it up)
> Hans> might be a better idea. <0.3 wink>
> I've considered that, and I really don't think it works in this case.
> You might think of the optional result as being similar to debugging
> information -- you really don't want to put the code that getnerates
> debugging information into a separate function, because then it will
> surely diverge from the code about which it is providing the information.

For debugging purposes, I'd store the debug info in the object
providing the member function in question. Works like a charm. As the
caller needs a reference to that object anyway, it is easier to
access the debug attribute than to test the shape of the return value.

Otherwise, I'd return an object instead of a tuple. Normally, speed
doesn't matter all that much after all -- otherwise we all would use
tuples instead of objects all the time <wink>.

Christian Tanzer                                         tanzer at
Glasauergasse 32                                       Tel: +43 1 876 62 36
A-1130 Vienna, Austria                                 Fax: +43 1 877 66 92

More information about the Python-list mailing list