Python - 文字列の中に単語があるかどうかを調べる

Python v2を使っているのですが、文字列の中に単語があるかどうかを知ることができるかどうかを調べています。

文字列の中に単語があるかどうかを特定する方法として、.findを使うという情報を見つけましたが、IF文を使う方法はありますか?以下のようなものが欲しいと思っています。

if string.find(word):
    print 'success'

ご協力ありがとうございました。

ソリューション

何がいけないのか。

if word in mystring: 
   print 'success'
解説 (5)
if 'seek' in 'those who seek shall find':
    print('Success!')

しかし、これは一連の文字にマッチするのであって、必ずしも単語全体にマッチするわけではないことに注意してください。例えば、 'swordsmith''word' は True です。単語全体にのみマッチさせたい場合は、正規表現を使うべきです。

import re

def findWholeWord(w):
    return re.compile(r'\b({0})\b'.format(w), flags=re.IGNORECASE).search

findWholeWord('seek')('those who seek shall find')    # -> 
findWholeWord('word')('swordsmith')                   # -> None
解説 (5)

findは、検索項目が見つかった場所のインデックスを表す整数を返します。 見つからなかった場合は-1を返します。

haystack = 'asdf'

haystack.find('a') # result: 0
haystack.find('s') # result: 1
haystack.find('g') # result: -1

if haystack.find(needle) >= 0:
  print 'Needle found.'
else:
  print 'Needle not found.'
解説 (0)