A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2001-August/017300.html below:

Generalizing "in" to pairs of sequences

[Python-Dev] Re: Generalizing "in" to pairs of sequencesKa-Ping Yee ping@lfw.org
Sun, 26 Aug 2001 02:25:31 -0700 (PDT)
On Sun, 26 Aug 2001, Eric S. Raymond wrote:
> This seems to be my week to ask simple, stupid questions.
>
> Is there any good semantic or philosophical reason that these aren't legal?

Yes.

> >>> "ab" in "cabcd"
> 1
> >>> "xy" in "cabcd"
> 0
> >>> (1, 2) in (0, 1, 2, 3)
> 1
> >>> (9, 8) in (0, 1, 2, 3)
> 0

The current meaning of "in" is:

    Given a sequence b, a is "in" b if a is an element of b.

Your "subsequence" interpretation would conflict with this meaning.
Here's current behaviour:

    >>> "ab" in ("ab", "cd")
    1
    >>> "ab" in ("a", "b", "c", "d")
    0
    >>> (1, 2) in ((0, 1), (1, 2), (2, 3))
    1
    >>> (1, 2) in (0, 1, 2, 3)
    0

"in" cannot have both meanings.


-- ?!ng

"Computers are useless.  They can only give you answers."
    -- Pablo Picasso



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4