ClassInstantiation
Used to create new instances of classes in Python.
import { ClassInstantiation } from "@alloy-js/python";
<ClassInstantiation args={Children[]} target={Children} />
import { ClassInstantiation } from "@alloy-js/python/stc";
ClassInstantiation({ args: Children[], target: Children }).children(children)
args | optionalChildren[] |
target | Children |
Remarks
Section titled “Remarks”It is similar to FunctionCallExpression but specifically for class instantiation. Args should be a list arguments that can be either simple js values or py.Atoms, which will render as positional arguments, or py.VariableDeclarations, which will render as named arguments in the call statement. This component will not check for the correctness of the python grammar and will just work with any children you provide. It is up to you to ensure that the arguments you provide are valid in the context of a class instantiation.
Example
Section titled “Example”<ClassInstantiation target="MyClass" args={["arg1", "arg2"]} />
This will generate:
MyClass(arg1, arg2)