genderize package

Module contents

Client for web service.

class genderize.Genderize(user_agent=None, api_key=None, timeout=30.0)[source]

Bases: object

Client for web service. Uses a Requests session for persistent HTTP connections.

get(names, country_id=None, language_id=None, retheader=False)[source]

Look up gender for a list of names. Can optionally refine search with locale info. May make multiple requests if there are more names than can be retrieved in one call.

  • names (Iterable[str]) – List of names.
  • country_id (Optional[str]) – Optional ISO 3166-1 alpha-2 country code.
  • language_id (Optional[str]) – Optional ISO 639-1 language code.
  • retheader (Optional[boolean]) – Optional

If retheader is False:
List of dicts containing ‘name’, ‘gender’,
‘probability’, ‘count’ keys. If ‘gender’ is None, ‘probability’ and ‘count’ will be omitted.
A dict containing ‘data’ and ‘headers’ keys. Data is the same as when retheader is False. Headers are the response header (a requests.structures.CaseInsensitiveDict). If multiple requests were made, the header will be from the last one.
Return type:Union[dict, Sequence[dict]]
Raises:GenderizeException – if API server returns HTTP error code.
get1(name, **kwargs)[source]

Look up gender for a single name. See get(). Doesn’t support retheader option.

exception genderize.GenderizeException[source]

Bases: exceptions.Exception

Exception from web service.