define 'in' operator on lists
Phil Frost
indigo at bitglue.com
Mon Oct 11 07:37:36 EDT 2004
On Mon, Oct 11, 2004 at 11:53:36AM +0200, ..:: sjf ::.. wrote:
> Hi all,
>
> I want to define 'in' operator (or any "magic" function) on list which
> returns True value if all of list (i.e. _list) elements appears in other
> list (i.e. L) in the same order and False otherwise. By way of example:
>
> L = [1, 2, 3, 4, 5, 6, 7]
> _list = [3, 4, 5]
>
> if L2 in L0:
> return True
> else:
> return False
>
> How to do that?
You might find that the 'sets' module does what you need.
More information about the Python-list
mailing list