Exception as the primary error handling mechanism?

Ben Finney ben+python at benfinney.id.au
Tue Jan 5 07:52:46 EST 2010


r0g <aioe.org at technicalbloke.com> writes:

> Paul Rudin wrote:
> > Doesn't python just return a single result? (I know it can be a
> > tuple and assignment statements will unpack a tuple for you.)
>
> Yes, it returns a tuple if you return more than one value, it just has
> a lovely syntax for it.

No, there is nothing inherent to the ‘return’ statement for dealing with
multiple values.

The ‘return’ statement *always* returns a single value: whatever value
you specify as the argument to the statement (or the value ‘None’ if no
argument is specified. If you specify a tuple — and Python has a nice
syntax for creating a literal tuple — that's the single value the
statement will use.

-- 
 \               “There's no excuse to be bored. Sad, yes. Angry, yes. |
  `\    Depressed, yes. Crazy, yes. But there's no excuse for boredom, |
_o__)                                          ever.” —Viggo Mortensen |
Ben Finney



More information about the Python-list mailing list