knit_script.knit_script_interpreter.statements.Push_Statement module
Statements that change the layer position of needles.
This module provides the Push_Statement class, which handles layer position modifications for needles in multi-sheet gauge configurations. It allows control over the stacking hierarchy of stitches, enabling complex knitting patterns that require specific layer arrangements.
- class Push_Statement(parser_node, needles, push_val)[source]
Bases:
Statement
Pushes needles to specified layer positions in the stacking hierarchy.
This statement modifies the layering order of stitches on needles, allowing control over which stitches appear in front or back of others in the final knitted fabric. Supports absolute positioning to specific layers, relative movement by distance, and convenient front/back positioning.
The push operation is essential for complex multi-sheet knitting where the layer ordering affects the final fabric structure and appearance. After modifying layer positions, the statement automatically resets to the current sheet to ensure the changes are properly applied.
- _needles
List of expressions that evaluate to needles whose layers should be repositioned.
- Type:
- _push_val
The positioning instruction specification.
- Type:
str | Expression | tuple[Expression, str]
- Parameters:
parser_node (
LRStackNode
)needles (
list
[Expression
])push_val (
str
|Expression
|tuple
[Expression
,str
])
- __init__(parser_node, needles, push_val)[source]
Initialize a push statement.
- Parameters:
parser_node (LRStackNode) – The parser node from the abstract syntax tree.
needles (list[Expression]) – List of expressions that evaluate to needles whose layers should be repositioned.
push_val (str | Expression | tuple[Expression, str]) – The positioning instruction, which can be a string for absolute positioning (“front” or “back”),
integer (an Expression for absolute layer position as)
of (or a tuple)
- execute(context)[source]
Execute the push operation on the specified needles.
Evaluates all needle expressions and applies the positioning operation to each needle’s layer in the gauged sheet record. Supports absolute positioning, relative movement, and convenient front/back shortcuts. After all modifications, resets to the current sheet to apply changes.
- Parameters:
context (Knit_Script_Context) – The current execution context of the knit script interpreter.
- Return type:
- __str__()[source]
Return string representation of the push statement.
- Returns:
A string showing the needles and push operation.
- Return type:
- __repr__()[source]
Return detailed string representation of the push statement.
- Returns:
Same as __str__ for this class.
- Return type:
- property line_number: int
Get the line number of the symbol that generated this statement.
- Returns:
The line number where this element appears in the source file.
- Return type:
- property location: Location
Get the location of this symbol in KnitScript file.
- Returns:
The location of this symbol in the source file, including file name, line number, and position information.
- Return type:
Location