Python handles globals badly.

Random832 random832 at fastmail.com
Tue Sep 8 20:02:24 EDT 2015


MRAB <python at mrabarnett.plus.com> writes:
> If you're allowed to specify both bounds, why would you be forbidden
> from negative ones?

It makes it non-obvious what value should be returned from e.g. search
methods that return a negative number on failure. .NET's IndexOf
function returns -1, but MaxValue if the array has a negative
bound. BinarySearch returns the complement of the nearest index to the
value you were searching for, which requires some gymnastics if you want
to make use of it for an array that has negative and positive bounds.




More information about the Python-list mailing list