{"id":6701,"library":"lib","title":"Autocode Standard Library Python Bindings","description":"The `lib` library provides basic Python bindings for interacting with the Autocode standard library, enabling users to call functions from deployed Autocode services. It serves as a zero-dependency interface to execute StdLib functions and automatically generates Python SDKs for services deployed to Autocode. The current version is 4.0.0, and the project is actively maintained.","status":"active","version":"4.0.0","language":"en","source_language":"en","source_url":"https://github.com/acode/lib-python","tags":["autocode","api-client","serverless","bindings","sdk"],"install":[{"cmd":"pip install lib","lang":"bash","label":"Install with pip"}],"dependencies":[],"imports":[{"symbol":"lib","correct":"from lib import lib"}],"quickstart":{"code":"from lib import lib\nimport os\n\n# Replace 'yourUsername' and 'yourService' with actual Autocode service details\n# and ensure the function 'myFunction' exists on that service.\n# The 'key' and 'value' parameters are example arguments for the function.\n# In a real scenario, you might interact with environment variables for API keys or service names.\n# For example, if your service requires an API key, you might pass it as an argument:\n# result = lib.yourUsername.yourService.myFunction(api_key=os.environ.get('AUTOCODE_API_KEY', ''))\n\ntry:\n    # Example: Call a function from a user's service\n    # This assumes 'yourUsername' has a service named 'yourService' with a default function\n    # that accepts a 'key' parameter.\n    result = lib.yourUsername.yourService(key='example_value')\n    print(f\"Service call successful: {result}\")\n\n    # Example: Call a specific function within a service, specifying environment\n    # result_dev = lib.yourUsername.yourService.myFunction['@dev'](another_key='test')\n    # print(f\"Dev service call successful: {result_dev}\")\n\nexcept RuntimeError as err:\n    print(f\"Error calling Autocode service: {err}\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to import the `lib` object and make a call to an Autocode service. Service calls are dynamically accessed via `lib.<username>.<service_name>.<function_name>` or `lib.<username>.<service_name>` for default functions. It also shows basic error handling."},"warnings":[{"fix":"Review the official release notes and changelog for detailed breaking changes and migration steps when upgrading to version 4.0.0 or higher. Thoroughly test your application after upgrading.","message":"Upgrading from `lib` v3.x to v4.x may introduce breaking changes. While specific migration guides were not found in the immediate search results, major version bumps in semantic versioning typically indicate incompatible API changes.","severity":"breaking","affected_versions":"<4.0.0"},{"fix":"Always wrap your `lib` calls in `try...except RuntimeError as err:` blocks to gracefully handle potential issues. Consult the Autocode documentation for specific error codes and messages from services.","message":"All interactions with Autocode services via `lib` are network calls and can result in `RuntimeError` due to issues like network failures, invalid service paths, or errors within the called Autocode function. It is crucial to implement robust error handling.","severity":"gotcha","affected_versions":"All"},{"fix":"Familiarize yourself with the Autocode ecosystem, including the Autocode CLI for service development and deployment, which can be found on the Autocode GitHub page.","message":"While the `lib` Python library itself has zero Python dependencies, its core utility relies on the Autocode platform. To build, deploy, or manage the services you call with `lib`, you will need to use the Autocode CLI and have an Autocode account.","severity":"gotcha","affected_versions":"All"},{"fix":"It is highly recommended to use `lib` with a supported Python 3.x version (3.6+). If Python 2.x compatibility is critical, pin to an older `lib` version known to work or rigorously test your application against the specific `lib` version.","message":"The `lib` library documentation mentions support for Python 2.x and 3.x. However, active development and the modern ecosystem typically prioritize Python 3.x. Users on older Python 2.x environments should thoroughly test compatibility, as future updates might implicitly favor Python 3.x practices or drop older support.","severity":"gotcha","affected_versions":"Python < 3.6"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}