Are multiple return values really harmful? (Re: determining the number of output arguments)

Robert Brewer fumanchu at amor.org
Tue Nov 16 23:55:24 EST 2004


Greg Ewing wrote:
> Jeremy Bowers wrote:
> > Generally, returning a tuple is either a sign that your return value
> > should be wrapped up in a class, or the function is doing too much.
> 
> While I suspect you may be largely right, I
> find myself wondering why this should be so. We
> don't seem to have any trouble with multiple inputs
> to a function, so why should multiple outputs be
> a bad thing? What is the reason for this asymmetry?
> 
> Perhaps it has something to do with positional vs.
> keyword arguments.

Hm. I'd guess it has more to do with arguments at all. That is, a
function has an input argument list which is metadata with respect to
the function body. There's no such "output argument list", at least not
specified in code. That's the fundamental asymmetry. Maybe we should
support:

def analysis(self, morf):
    filename, statements = self.analyze_morf(morf)
    missing = []
    for line in statements:
        if not self.cexecuted[filename].has_key(line):
            missing.append(line)
end analysis(filename, statements, missing,
             self.format_lines(statements, missing))


/ducking and running ;)


Robert Brewer
MIS
Amor Ministries
fumanchu at amor.org



More information about the Python-list mailing list