stylistic question -- optional return value

Erik Max Francis max at alcyone.com
Wed Aug 28 16:23:09 EDT 2002


Stefan Schwarzer wrote:

> A variant of returning a tuple but with more readability could be:
> 
> -----
> # you may use another name
> class ValueWithDebugInfo:
>      pass
> 
> class X:
>      def do_something(self):
>          ...
>          result = ValueWithDebugInfo()
>          result.that_what_i_want = ...
>          result.debug_info = ...
>          return result

Why not just skip the middle man and return a dictionary?  After all,
you're only really using the class instance for its __dict__ attribute
dictionary anyway.  Seems more direct to just return a dictionary.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/  \ There is nothing so subject to the inconstancy of fortune as war.
\__/ Miguel de Cervantes
    Church / http://www.alcyone.com/pyos/church/
 A lambda calculus explorer in Python.



More information about the Python-list mailing list