Runtime v2.81 · Updated Sep 30, 2026

tuple

An ordered read-only collection.

Syntax

tuple(iterable=(), /)
(value1, value2, ...)

Parameters

None

Returns

tuple

Behavior / side effects

An ordered read-only collection. Use tuple literals when values should stay fixed after creation or when returning grouped values for destructuring.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

offset = (0, 1)
x = offset[0]
y = offset[1]
if 1 in offset:
    text("offset ready")

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

None

Methods

9 methods

tuple.constructor

Create an empty tuple or clone another iterable as tuple.

Syntax

tuple()
tuple(iterable, /)

Parameters

NameDescription
iterableIterable
Optional iterable to clone into a tuple.
Depends on overload · Positional only
Default: None

Returns

tuple — A new read-only tuple.

Behavior / side effects

Create an empty tuple or clone another iterable as tuple. Use a tuple literal for multiple inline values.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

coords = (120, 340)
copy = tuple(coords)

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

tuple.literal

Create a tuple inline using parentheses and commas.

Syntax

(value1, value2, ...)

Parameters

NameDescription
valueAny?
Each item written inside tuple parentheses.
Required · Positional or named
No default

Returns

tuple — A new tuple preserving literal order.

Behavior / side effects

Create a tuple inline using parentheses and commas.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

offset = (0, 1)
click(Point(500, 900), offset=offset)

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

tuple.length

Count how many items are in the tuple.

Syntax

len(tuple, /)

Parameters

NameDescription
tupletuple
The tuple to count.
Required · Positional only
No default

Returns

Int — Number of tuple items.

Behavior / side effects

Count how many items are in the tuple.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

offset = (0, 1)
count = len(offset)      # returns 2

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

tuple.index_access

Read one tuple item by index.

Syntax

tuple[index]

Parameters

NameDescription
tupletuple
Source tuple.
Required · Positional or named
No default
indexInt
Item index. Use -1 for the last item.
Required · Positional only
No default

Returns

Any? — tuple item at index, or None when out of range.

Behavior / side effects

Read one tuple item by index. Negative indexes count from the end.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

pair = (10, 20)
x = pair[0]              # returns 10
y = pair[-1]             # returns 20

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

tuple.slice

Copy part of a tuple using Python-style slicing.

Syntax

tuple[start:end[:step]]

Parameters

NameDescription
startInt
First item index to include.
Optional · Positional only
Default: start of tuple
endInt
Stop before this item index.
Optional · Positional only
Default: end of tuple
stepInt
Distance between items. Cannot be 0; negative values read backward.
Optional · Positional only
Default: 1

Returns

tuple — A new tuple slice, clamped to the available range.

Behavior / side effects

Copy part of a tuple using Python-style slicing. Omitted bounds use the start or end; negative indexes count from the end.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

values = (0, 1, 2, 3, 4)
middle = values[1:4]     # returns (1, 2, 3)
reverse = values[::-1]   # returns (4, 3, 2, 1, 0)

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

tuple.destructuring_assignment

Unpack tuple items into matching assignment targets.

Syntax

x, y = tuple

Parameters

NameDescription
x, yTargets
Assignment targets matching the tuple item count.
Required · Positional or named
No default
tupletuple
Source tuple to unpack.
Required · Positional only
No default

Returns

None — No direct return value. Targets receive tuple items left to right.

Behavior / side effects

Unpack tuple items into matching assignment targets. Nested targets are supported, but starred targets such as *rest are not supported.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

label, (x, y) = ("target", (500, 900))

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

tuple.index_method

Find the first matching item index and fail visibly when absent.

Syntax

tuple.index(value, start=0, stop=len(tuple), /)

Parameters

NameDescription
valueAny?
Value that must exist in the tuple.
Required · Positional only
No default
startInt
Start index for the search.
Optional · Positional only
Default: 0
stopInt
Stop index for the search.
Optional · Positional only
Default: len(tuple)

Returns

Int — First matching item index.

Behavior / side effects

Find the first matching item index and fail visibly when absent.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

pair = ("farm", "pvp")
index = pair.index("pvp")

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

tuple.count_method

Count matching tuple items.

Syntax

tuple.count(value, /)

Parameters

NameDescription
valueAny?
Value to count.
Required · Positional only
No default

Returns

Int — Number of matches.

Behavior / side effects

Count matching tuple items.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

pair = ("farm", "farm", "pvp")
count = pair.count("farm")

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

tuple.for_loop

Iterate tuple items from left to right.

Syntax

for item in tuple:

Parameters

NameDescription
itemAny
Current tuple item in loop.
Required · Positional or named
No default
tupletuple
tuple to iterate.
Required · Positional or named
No default

Returns

None — No direct return value.

Behavior / side effects

Iterate tuple items from left to right.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

offset = (0, 1)
for item in offset:
    text(str(item))

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs