def GetCookieFromResponse(response):
 user_cookie_header_list = [h for h in response.headers.get_list('Set-Cookie') if h.startswith('user=')]
 if (not user_cookie_header_list):
  return None
 return re.match('user="?([^";]*)', user_cookie_header_list[(-1)]).group(1)

def GetCookieFromResponse ( response ) : user_cookie_header_list = [ h for h in response . headers . get_list ( 'Set-Cookie' ) if h . startswith ( 'user=' ) ] if ( not user_cookie_header_list ) : return None return re . match ( 'user="?([^";]*)' , user_cookie_header_list [ ( - 1 ) ] ) . group ( 1 )
extracts the user cookie from an http response and returns it if it exists .