jsii Python Client

1.127.0 · active · verified Mon Apr 06

jsii is an open-source framework developed by AWS that enables code in any language (such as Python, Java, C#, and Go) to naturally interact with JavaScript classes authored in TypeScript. It is a core technology behind the AWS Cloud Development Kit (CDK), allowing polyglot libraries to be delivered from a single TypeScript codebase. The project is actively maintained by AWS, with frequent updates to the compiler, pacmak (bindings generator), and runtime libraries.

Warnings

Install

Imports

Quickstart

The `jsii` library itself provides the runtime for generated modules. Python developers primarily interact with packages that have been *generated* by jsii (e.g., AWS CDK constructs). These generated packages depend on `jsii`. The example above illustrates how you would typically use a class from such a generated library.

import os
from some_jsii_generated_lib import HelloJsii

# NOTE: In a real scenario, 'some_jsii_generated_lib' would be a library
# generated by jsii (e.g., AWS CDK, or your own jsii module) which has
# 'jsii' as a dependency. The 'HelloJsii' class would be defined in TypeScript.

# Example of using a class from a jsii-generated Python library
try:
    # Assuming HelloJsii class and say_hello method are available
    # This code is illustrative; replace with actual generated lib usage.
    hello_instance = HelloJsii()
    message = hello_instance.say_hello("World")
    print(message)
except ImportError:
    print("To run this, you need a jsii-generated library installed.")
    print("For example, 'pip install aws-cdk.core' and then use CDK classes.")
except Exception as e:
    print(f"An error occurred: {e}")

view raw JSON →