title: python group file names by exact string
body: <p>I am trying to group file names by specific ID, here is what I have so far:</p>
  
  <pre><code>(ccc)khine@dhegdheer:~/Sandboxes/Business/continentalclothing.com$ python
  Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
  [GCC 4.8.2] on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  &gt;&gt;&gt; cropped = ['ccc-public,assets/cropped/low_res/EP01.jpg', 'ccc-public,assets/cropped/low_res/EP01L.jpg', 'ccc-public,assets/cropped/low_res/EP01_10.jpg', 'ccc-public,assets/cropped/low_res/EP01_20_1.jpg', 'ccc-public,assets/cropped/low_res/EP01_21_1.jpg', 'ccc-public,assets/cropped/low_res/EP02.jpg', 'ccc-public,assets/cropped/low_res/EP03.jpg', 'ccc-public,assets/cropped/low_res/EP03V.jpg']
  &gt;&gt;&gt; styles = ['EP01', 'EP01L', 'EP02', 'EP03', 'EP03V']
  &gt;&gt;&gt; def get_cropped(style):
  ...     cropped_images = []
  ...     matching = [key for key in cropped if style in key.rsplit('/', 1)[1]]
  ...     for x in matching:
  ...             cropped_images.append(x)
  ...     return cropped_images
  ... 
  &gt;&gt;&gt; for style in styles:
  ...     get_s3_images = get_cropped(style)
  ...     for x in get_s3_images:
  ...             print x
  ... 
  assets/cropped/low_res/EP01.jpg
  assets/cropped/low_res/EP01L.jpg
  assets/cropped/low_res/EP01_10.jpg
  assets/cropped/low_res/EP01_20_1.jpg
  assets/cropped/low_res/EP01_21_1.jpg
  assets/cropped/low_res/EP01L.jpg
  assets/cropped/low_res/EP02.jpg
  assets/cropped/low_res/EP03.jpg
  assets/cropped/low_res/EP03V.jpg
  assets/cropped/low_res/EP03V.jpg
  </code></pre>
  
  <p>What is the correct way to extract all paths that contain EP01, so I get a list like</p>
  
  <pre><code>    "/assets/cropped/low_res/EP01.jpg",
      "/assets/cropped/low_res/EP01_10.jpg",
      "/assets/cropped/low_res/EP01_20_1.jpg",
      "/assets/cropped/low_res/EP01_21_1.jpg"
  </code></pre>
  
  <p>excluding <code>"/assets/cropped/low_res/EP01L.jpg",</code> entry and for <code>EP01L</code> to return, just <code>&lt;Key: ccc-public,assets/cropped/low_res/EP01L.jpg&gt;</code></p>
  
  <p>Any advice much appreciated</p>