stylistic question -- optional return value

Erik Max Francis max at alcyone.com
Thu Aug 29 21:31:44 EDT 2002


Paddy McCarthy wrote:

> If there IS no sentinel value i.e. you want to allow x and y to take
> any
> value then you either have to supply a third flag value as above, or
> maybe
> encode the return value if return is a tuple of two values then x and
> y
> are those values, otherwise the return value is a tuple whose first
> element is x.

Not true; as I pointed out with sample code, you can create a unique
sentinel object, stick it in the class, and use that as the
representation of the sentinel value.  No other object will test
equivalent to that unique sentinel object with the is operator.

-- 
 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 mailing list