Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; '"c"': 0.07; 'character,': 0.07; 'function:': 0.09; 'substring': 0.09; 'sucks': 0.09; 'def': 0.10; '"b"': 0.16; 'from:addr:ian': 0.16; 'string:': 0.16; 'string': 0.17; 'wrote:': 0.17; '>>>': 0.18; 'define': 0.20; 'received:192.168.1.100': 0.22; 'work.': 0.23; 'statement': 0.23; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'received:208.97': 0.29; 'received:208.97.132': 0.29; 'received:66.33': 0.29; 'received:66.33.216': 0.29; 'received:66.33.216.122': 0.29; 'received:dreamhost.com': 0.29; 'received:g.dreamhost.com': 0.29; 'received:hapkido.dreamhost.com': 0.29; 'figure': 0.30; 'could': 0.32; 'to:addr:python-list': 0.33; 'false': 0.35; "won't": 0.35; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'header:Received:5': 0.40; 'most': 0.61; 'received:208': 0.63; 'charset:windows-1252': 0.65; 'substrings': 0.84 DomainKey-Signature: a=rsa-sha1; c=nofws; d=feete.org; h=message-id:date:from :mime-version:to:subject:references:in-reply-to:content-type: content-transfer-encoding; q=dns; s=feete.org; b=L2mlA7yXD5T9TyM 9xKcsusEMhCp5HKY2kkxT1MTSLJdRut4xauNqupWO2SxSxtuI4wfw55+cr4S9kNF +iDx9Jl2gvezCYNoMKB7B4/koZaX5bNY6bJy1CRT4zxZjcIJQEbdFET1YYyJhwmO te3V2AESvr2dKtorPmb3/5perbKk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=feete.org; h=message-id :date:from:mime-version:to:subject:references:in-reply-to :content-type:content-transfer-encoding; s=feete.org; bh=jmHYQa+ 2RkwXCuZDgFaLPbA2Z+k=; b=sI8bLx5AygG0VI5JBeBGHNJVcU9SKVm50g0LQr2 aFFOgidKt7G2NzG6LX/rn3YbPIFjEvRTZotf2B7/dmvpQsJsSjshKt9BrDGimgKo 3aHJH5Ati2plNQ/6YWS/XMYuLsHjdRY+3ZLqq9I6/kIG4xEl/4B6vkbtn3JYEd7/ xCq8= Date: Wed, 22 Aug 2012 04:42:55 +0100 From: Ian Foote User-Agent: Mozilla/5.0 (X11; Linux i686; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: asking References: In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1345607418 news.xs4all.nl 6853 [2001:888:2000:d::a6]:55474 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:27601 On 22/08/12 03:57, mingqiang hu wrote: > can I use just one statement to figure out if substring =93a=94 ,"b" "c= "=20 > are in string "adfbdfc" ? not use the statement like > > ("a" in "adfbdfc") or ( "b" in "adfbdfc") or ("c" in "adfbdfc" )=20 > ,because if I have lots of substring, this could sucks This might not be the most efficient way, but: >>> set("abc") <=3D set("adfbdfc") True >>> set("abce") <=3D set("adfbdfc") False If you want to check for substrings longer than one character, this=20 won't work. A solution then is to define a custom function: def all_in(string, substrings): for substring in substrings: if substring not in string: return False return True Ian