A very simple Python library providing human-understandable HTTP status codes and helper methods to improve code readability. Originally forked from Django Rest Framework, it reached version 1.0.1 in October 2015 and has not seen further updates since, making it an effectively abandoned project.
pip install python-statusVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to import and use the `status` library with HTTP status codes and helper functions, often in conjunction with a library like `requests`.
Migrate to the standard library's `http.HTTPStatus` (available in Python 3.5+), which provides similar functionality and is actively maintained. Alternatively, consider `requests.Response.raise_for_status()` for basic error checking or `httpx` for modern HTTP client needs.
Replace `import status` with `from http import HTTPStatus`. Use `HTTPStatus.OK` instead of `status.HTTP_200_OK` and `HTTPStatus.OK.value` for the integer code. For `is_success`, `is_client_error`, etc., you may need to implement custom helper functions or use integer comparisons, e.g., `200 <= code < 300`.
Check your Python environment and if it's 3.5 or newer, prefer `http.HTTPStatus`. If you must use `python-status` for legacy reasons, ensure your environment is Python 3.5 or older.
Run `pip install python-status` to install the library.
Upgrade to `http.HTTPStatus` from the standard library. Newer Python versions' `HTTPStatus` enum will include more recently defined codes. If using an old Python and stuck with `python-status`, you might need to use the raw integer value for less common or newer status codes.
Access status codes as attributes (e.g., `status.HTTP_200_OK`) or call helper functions with arguments (e.g., `status.is_success(code=200)`). Do not attempt to call `status()` directly.
No dependency data recorded yet.