def redirected(url, location):
 r = requests.get(url, allow_redirects=False)
 status = (r.status_code in (301, 302))
 redirect = (('location' in r.headers) and (r.headers['location'] == location))
 return all([status, redirect])

def redirected ( url , location ) : r = requests . get ( url , allow_redirects = False ) status = ( r . status_code in ( 301 , 302 ) ) redirect = ( ( 'location' in r . headers ) and ( r . headers [ 'location' ] == location ) ) return all ( [ status , redirect ] )
return true if url is redirected to location .