David C. Ullrich wrote:
In article <[EMAIL PROTECTED]>,
 Terry Reedy <[EMAIL PROTECTED]> wrote:

Is there a reason for the inconsistency? I would
have thought "in" would check for elements of a
sequence, regardless of what sort of sequence it was...
It is not an inconsistency but an extension corresponding to the limitation of what an string element can be.

It's an inconsistency. That doesn't mean it's a bad thing or that
I want my money back. It may well be a reasonable inconsistency -
strings _can_ work that way while it's clear lists had better not.
But it's an inconsistency.

To decisively argue 'inconsistency' as factual or not, versus us having divergent opinions, you would have to supply a technical definition ;-) The math definition of 'leading to a contradiction' in the sense of being able to prove False is True, does not seem to apply here.

However,
a) In common English, 'in' and 'contains', applied to strings of characters (text), is understood as applying to substrings that appear in the text. This is also true of many other programming languages. 'Dictionary' contains 'diction'. This is even the basis of various word games. b) Python otherwise allows operators to vary in meaning for different classes.

In any case, back to your original question: the extension of meaning, 'inconsistent' or not, was deliberated and adopted on the basis that the usefulness of the extension would outweigh the confusion wrought by the class-specific nature of the extension. (In other words, threads such as this *were* anticipated ;-)

Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to