Registry / http-networking / hammock

hammock

JSON →
library0.2.4pypypi✓ verified 22d ago

Hammock is a lightweight Python library designed to provide a Pythonic interface for interacting with REST APIs. The current version is 0.2.4. Based on its last commit and release in 2017, the library is no longer actively maintained and appears to be abandoned, likely developed primarily for Python 2.

pip install hammock
INSTALL
IMPORT
SIG · HAMMOCK
H
hammock
http-networkingpythonv0.2.4
Install
3.0s avg
Import
351ms
Disk
20MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.2.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.356s · 22.5MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.0s · import 0.346s · 23MB
20MB installed
● package 20MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Hammock
from hammock import Hammock

Demonstrates initializing Hammock and performing a basic GET request against the GitHub API to fetch user details. The response data is accessible via dot notation.

import os from hammock import Hammock # Hammock provides a Pythonic way to interact with REST APIs. # For this public GitHub API endpoint, no authentication is strictly needed. # For APIs requiring auth, you would typically pass headers or auth parameters # during Hammock initialization or within specific HTTP method calls. # For example: auth_token = os.environ.get("GITHUB_TOKEN", "") github = Hammock("https://api.github.com") # Perform a GET request to retrieve information about the 'octocat' user. # Hammock allows chaining attributes for URL segments (e.g., .users('octocat')). user_data = github.users('octocat').GET() # The response data can be accessed like attributes or dictionary keys. print(f"Octocat's name: {user_data.name}") print(f"Octocat's public repositories: {user_data.public_repos}") print(f"Octocat's followers: {user_data.followers}")
Debug
Known issues
gotchaThe `hammock` library is unmaintained and effectively abandoned. Its last commit and release date back to 2017. This means it receives no updates, bug fixes, or security patches, and may not be compatible with newer Python versions or evolving API standards.
fix
It is strongly recommended to use actively maintained HTTP client libraries such as `requests`, `httpx`, or more modern API client generators for robust and secure applications. Consider this library for historical reference or very limited, non-production use cases only.
affects: All versions (0.2.4 and earlier)
breakingHammock was primarily developed with Python 2 in mind. While it might function with some Python 3 versions, it is not officially tested or supported for modern Python 3.x environments. This can lead to unexpected behavior, deprecated syntax, or runtime errors.
fix
If considering its use, thoroughly test all functionality on your target Python 3 version. However, for any new project, choosing a Python 3 native and actively maintained library is a far more reliable approach.
affects: All versions (0.2.4 and earlier)
gotchaAs a lightweight and older library, Hammock lacks many advanced features common in modern HTTP clients, such as automatic request retries, robust connection pooling, asynchronous support, or sophisticated error handling mechanisms. This can make building resilient applications challenging without significant custom wrappers.
fix
Implement custom retry logic, error handling, and timeout mechanisms manually, or opt for a modern HTTP client library that includes these features out-of-the-box.
affects: All versions (0.2.4 and earlier)
Errors
Common errors & fixes
SyntaxError: Missing parentheses in call to 'print'
The 'hammock' library was developed for Python 2, where 'print' was a statement. When run in Python 3, 'print' became a function and requires parentheses.
fix
Migrate your code to use the 'print()' function syntax in Python 3, or use Python 2.7 to run the 'hammock' library. For Python 3 compatibility without modifying 'hammock' itself, you would typically fix any calling code that uses Python 2 print statements.
TypeError: Object of type Response is not JSON serializable
This error occurs when attempting to directly serialize a 'hammock' response object (which is a 'requests.Response' object under the hood) to JSON without first extracting the JSON data from it, typically by calling the `.json()` method.
fix
Access the JSON content from the response object by calling its `.json()` method before attempting to serialize it or use it as a JSON object, e.g., `data = response.json()`.
UnicodeDecodeError: 'ascii' codec can't decode byte 0x... in position ...: ordinal not in range(128)
'hammock' is a Python 2 library, and Python 2 handles strings as byte sequences. When such code is executed in Python 3, which treats strings as Unicode by default, operations involving implicit string conversions with non-ASCII characters can lead to 'UnicodeDecodeError' or similar encoding issues.
fix
Ensure all strings passed to or received from 'hammock' are explicitly encoded/decoded. For Python 3, bytes objects should be decoded to strings using a known encoding (e.g., `.decode('utf-8')`), and strings should be encoded to bytes when necessary (e.g., `.encode('utf-8')`). Given the library's abandonment, a full Python 3 port or a wrapper for encoding/decoding may be necessary.
AttributeError: 'Distribution' object has no attribute 'entry_points'
This error typically occurs during the installation process with 'pip' in certain Python 3.x environments (like Python 3.6 with older 'pip' versions) due to incompatibilities between 'setuptools' and the environment, often triggered when a legacy package like 'hammock' is in the dependency tree.
fix
Upgrade your 'setuptools' package to a newer version by running `pip install --upgrade setuptools`, and potentially upgrade 'pip' itself with `pip install --upgrade pip`. Consider using a virtual environment to manage dependencies more cleanly.
Upgrade
Version history
0.2.4latest on PyPI · released Apr 21, 2013
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
Resources