"Paul Rubin" <"http://phr.cx"@NOSPAM.invalid> wrote in message news:[EMAIL PROTECTED] > Steve Holden <[EMAIL PROTECTED]> writes: >> Of course. But onc you (sensibly) decide to use an "if" then there >> really isn't much difference between -1, None, () and sys.maxint as >> a sentinel value, is there? > > Of course there is. -1 is (under Python's perverse semantics) a valid > subscript. sys.maxint is an artifact of Python's fixed-size int > datatype, which is fading away under int/long unification, so it's > something that soon won't exist and shouldn't be used. None and () > are invalid subscripts so would be reasonable return values, unlike -1 > and sys.maxint. Of those, None is preferable to () because of its > semantic connotations.
I agree here that None is importantly different from -1 for the reason stated. The use of -1 is, I am sure, a holdover from statically typed languages (C, in particular) that require all return values to be of the same type, even if the 'return value' is actually meant to indicat that there is no valid return value. Terry J. Reedy -- http://mail.python.org/mailman/listinfo/python-list