stylistic question -- optional return value
Erik Max Francis
max at alcyone.com
Wed Aug 28 23:22:37 CEST 2002
Andrew Koenig wrote:
> Paddy> I would suggest something like (True, x, y) and (False, x, y)
> Paddy> where False means disregard any y value. You could then
> Paddy> consistently assign the return value of your function to three
> Paddy> variables and examine the first to see if y contains useful
> Paddy> data.
> Hmmm... I think I like the (x, y) or (x, sentinel) idea better,
> assuming that (x, y) or (x, None) isn't acceptable.
I agree. Adding the additional element that acts as a "key" as to what
follows seems rather distasteful. I've done this a few times, mostly
for quick hacks, but I've never been particularly proud of it. (In all
cases it was not part of some important API that external people would
have to use.)
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