"in" operator for strings

Magnus Lie Hetland mlh at idi.ntnu.no
Sun Feb 4 09:55:04 EST 2001


"Alex Martelli" <aleaxit at yahoo.com> wrote in message
news:95gkgg0fo7 at news1.newsguy.com...
> "Magnus Lie Hetland" <mlh at idi.ntnu.no> wrote in message
> news:95ftl4$o6b$1 at tyfon.itea.ntnu.no...
>     [snip]
> > > > only allow contiguous subsequences, or any subsequence?
> > > > If we ever get built-in sets contiguity would be meningless,
> > > > as would it be if we get "in" tests for dictionaries.)
> > >
> > > Dictionaries aren't sequences, nor will sets be, so the
> > > issue doesn't apply to either.
> >
> > Sure it does. It will then become the question of whether to
> > allow the same operator do check membership and subset-ness.
>
> Subsetness is one thing, subsequencehood another (actually
> two others, given contiguity may be required or not); the
> difference is ordering -- 'ab' is a subset but not a subsequence
> of 'obak'.  The whole issue of subsequence is meaningless
> where no sequence (ordering) exists.

Yes. I am well aware of that, and it seems that I mangled up
my original sentence a bit. My *real* point (as illustrated
by the examples and exmplanation of characters *in* strings
etc.) was the difference between elements and subsets
(or substrings, or subsequences). Order is irrelevant here,
and the ambiguity is very real. The contiguity is an added
problem. As I state above, in sets and dictionaries
contiguity would be meaningless, and thus not part of
the issue. It would seem to me that you agree on that
point? (So why object? <wink>)

> I like the clarity that comes from use of explicit prefixes --
> no wondering 'WHAT split function is this one' any more
> (string or re or ...?).  Calling a method of an object, as in
> 'foo bar'.split(), is clearest -- totally local context, zero
> wondering-factor.  Calling a prefixed function is second
> best.  Calling a non-prefixed function sends me looking for
> it throughout the non-necessarily-small module -- and
> I won't find the '^def split' either (so I have to look at the
> from statements and the assignments -- sigh).

Hm. OK.

> > The " ".join([1,2,3]) doesn't seem like an accessor to me.
> > It seems like a plain function with a weird syntax.
> >
> > But, hey, since this is the way it *is*, I'm the one with
> > a problem here :-)
>
> And we're here to help you come to terms with it!-)

And I thank you for it :)

> Alex

--

  Magnus Lie Hetland      (magnus at hetland dot org)

 "Reality is what refuses to disappear when you stop
  believing in it"                 -- Philip K. Dick






More information about the Python-list mailing list