Basic usage¶
Import the Genderize
class and call its get
method with a list of names.
from genderize import Genderize
print(Genderize().get(['James', 'Eva', 'Thunderhorse']))
[{u'count': 1037, u'gender': u'male', u'name': u'James', u'probability': 0.99},
{u'count': 234, u'gender': u'female', u'name': u'Eva', u'probability': 1.0},
{u'gender': None, u'name': u'Thunderhorse'}]
Shell usage¶
If run as a script, takes a list of names on stdin, and prints them with their genders.
echo "James\nEva\nThunderhorse" | python -m genderize
James: male
Eva: female
Thunderhorse: None
Advanced usage¶
Create a Genderize
instance with a custom user agent,
an API key,
and a shorter timeout than the default 30 seconds.
Note that you’ll need to use your own API key or this example won’t work.
from genderize import Genderize
genderize = Genderize(
user_agent='GenderizeDocs/0.0',
api_key='example_api_key',
timeout=5.0)
print(genderize.get(['James', 'Eva', 'Thunderhorse']))
[{u'count': 1037, u'gender': u'male', u'name': u'James', u'probability': 0.99},
{u'count': 234, u'gender': u'female', u'name': u'Eva', u'probability': 1.0},
{u'gender': None, u'name': u'Thunderhorse'}]
Maintenance¶
Setup for local development:
virtualenv --prompt '(genderize) ' venv -p python3
pip install -r requirements.txt
pip install -r requirements-dev.txt
Release checklist:
- Generate a new version number:
major.minor.micro
. It should be compatible with both PEP 440 and SemVer 2.0.0. - Update
__version__
ingenderize/__init__.py
. This is read bysetup.py
and doesn’t need to be changed there. - Add a changelog entry and date for the new version in
CHANGES.rst
. - Commit the changes. This may be done as part of another change.
- Tag the commit with
git tag major.minor.micro
. - Push the tag to GitHub with
git push origin major.minor.micro
. - Travis will create a new PyPI release from the tag.
API docs¶
Change Log¶
0.3.0¶
2018-12-21
- Added support for Requests connection/read timeouts, with a default of 30 seconds.
- Now tested on Python 3.7.
- Added fix to
.travis.yml
for broken PyPI publishing. See travis-ci/dpl #861 and Releasing build artifacts.
0.2.0¶
2018-05-15
- Now respects the API limit of 10 names per request, and will break up larger name lists into multiple API requests transparently. This closes issue #6, reported by neginahoomi.
- Now tested on Python 3.6, PyPy 2, and PyPy 3 as well, and generates Codecov coverage reports.
- Dropped support for Python 2.6 and 3.2.
- Updated author’s contact info.
0.1.5¶
2015-10-09
- Incorporated vionemc’s patch for optionally returning response headers. Anyone that wants to inspect the rate limit headers should set retheader=True.
- Now tested on Python 3.5 as well.
0.1.4¶
2015-06-21
- Switched to HTTPS endpoint.
- Incorporated granteagon’s patch for _fixtypes.
- Added support for paid API keys.
- Included Sphinx API docs.
0.1.3¶
2015-01-16
- Supports Python 2.6, 2.7, 3.2, 3.3, and 3.4.
- Added an integration test that calls the Genderize.io API server.
- Now using Travis CI.