Good style for multi-valued returns
Mitch Chapman
chapman at bioreason.com
Thu Apr 20 16:30:17 EDT 2000
More information about the Python-list mailing list
Thu Apr 20 16:30:17 EDT 2000
- Previous message (by thread): Good style for multi-valued returns
- Next message (by thread): Good style for multi-valued returns
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Cameron Laird wrote: > > Examples of multi-valued returns: (head, tail); (quotient, > remainder); (left, right); (prologue, body, epilogue); > (data, code); (CAR, CDR); (count, size); (handle, status); > (decomposition; remainder); ... > > Let me guess: folks generally pass tuples for small and > determinate-in-number multi-values, and dictionaries other- > wise, 'cept some do it all with tuples. Accurate? If there are many returned values, I tend to define a new class for the return type rather than returning a dictionary. This usually pays off, because the consumers of those return values often want to perform the same sorts of operations on the values. If I start off representing the return value as a dictionary, clients duplicate the logic for those operations. If I start off with a class for the new return type, those operations get expressed once, as methods of the new class. -- Mitch Chapman chapman at bioreason.com
- Previous message (by thread): Good style for multi-valued returns
- Next message (by thread): Good style for multi-valued returns
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list