def urlsafe_base64_encode(s):
 return base64.urlsafe_b64encode(s).rstrip('\n=')

def urlsafe_base64_encode ( s ) : return base64 . urlsafe_b64encode ( s ) . rstrip ( '\n=' )
encodes a bytestring in base64 for use in urls .