Exception as the primary error handling mechanism?

r0g aioe.org at technicalbloke.com
Tue Jan 5 15:21:05 CET 2010


Ben Finney wrote:
> 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.
> 



That's what I said Ben...

>>> Doesn't python just return a single result?

>> Yes,


See how I agree that "The ‘return’ statement *always* returns a single
value"?



>> it returns a tuple if you return more than one value, it just has
>> a lovely syntax for it.

You're confusing literal and conceptual returns. You can tell there are
two senses of return at play because the two returns have different
possessives within the same sentence. Look...

"Yes, IT returns a tuple" - Speaking literally about Python...

return 1, 2, 3   # Python returned one value

"YOU return more than one value" - Speaking conceptually from a
programmers perspective.

return 1, 2, 3   # I returned three values

Both are valid in their own context. The second (conceptual) statement
MIGHT be ambiguous if it weren't for the first literal one. Both cannot
be literally true and the first one clearly IS a literal factual
statement about Python so the second cannot also be interpreted as
literal. So let's disgard it...

>> it returns a tuple, it just has a lovely syntax for it.

The first two "it"s are Python, the third could either be...

(a) The construction of tuples

or at a stretch...

(b) The act of returning tuples i.e. some special syntax for returning
tuples.


You seem to think I meant (b) - I actually meant (a)

Maybe I could have made that clearer but I don't think people want to
read legalese and I think it takes a particular pedantic, nitpicking
disposition to even spot such small ambiguities.

Of course I'm now guilty of pedantry too :/ I might have let it slip had
you not started your reply with the word "No", that just p***** me off.

Having said that I find the mental image of you slamming your fist on
the table and shouting it out loud whenever you read something you
disagree with on usenet quite amusing!

Roger.



More information about the Python-list mailing list