def get_country_code(request):
 if ('X-AppEngine-Country' in request.headers):
  if (request.headers['X-AppEngine-Country'] in pytz.country_timezones):
   return request.headers['X-AppEngine-Country']
 return None

def get_country_code ( request ) : if ( 'X-AppEngine-Country' in request . headers ) : if ( request . headers [ 'X-AppEngine-Country' ] in pytz . country_timezones ) : return request . headers [ 'X-AppEngine-Country' ] return None
country code based on iso 3166-1 .