title: Python 2: one-line or very compact code to check "startswith" across several strings?
body: <p>The scenario:</p>
  
  <p>I have a list:</p>
  
  <pre><code>['item','place','thing']
  </code></pre>
  
  <p>And I have some strings:</p>
  
  <pre><code>"item", "item1", "thing55", "place_C", "stuff", "junk5"
  </code></pre>
  
  <p>Of the above, I want the first four to match, and the last two to not match. The startswith function is most appropriate for this check.</p>
  
  <p>(The list of test strings "item", "item1", etc. is not a python list; it's just a set of sample data that might be checked. However, the list of strings to match against "item","place","thing" IS a python list in code.)</p>
  
  <p>I could iterate through the first list and compare the string with startswith:</p>
  
  <pre><code>successVar = False
  for s in myStrings:
      if (testString.startswith(s)): 
          successVar = True
          break
  #  Now you would check successVar to decide if string matched
  </code></pre>
  
  <p>But this doesn't necessarily work best in all cases. For example, suppose this is part of an if/elif structure:</p>
  
  <pre><code>if (testString == "hello"):
      # do something based on exact string match
  elif (testString.endswith("!")):
      # do something if string ends with _one_ specific entity
  elif &lt;somehow, do the above comparison in here&gt;
      # do something if string starts with any of the items in a list
  else:
      # do something if string didn't match anything
  </code></pre>
  
  <p>I suppose I could wrap the entire check inside a function, but it feels to me like there might be a way to do this with inline code more easily or more concisely.</p>
  
  <p>Is this even possible to do without making a function?</p>
  
  <p>Thanks</p>