InitFunctionDeclaration
A Python __init__
function declaration.
import { InitFunctionDeclaration } from "@alloy-js/python";
<InitFunctionDeclaration />
import { InitFunctionDeclaration } from "@alloy-js/python/stc";
InitFunctionDeclaration({ }).children(children)
Remarks
Section titled “Remarks”This is a convenience component that sets the name to __init__
, marks it as
an instance function, and forces the name to be __init__
without applying
the name policy.
Example
Section titled “Example”<InitFunctionDeclaration> self.attribute = "value"</InitFunctionDeclaration>
This will generate:
def __init__(self: MyClass) -> None: self.attribute = "value"