{ } Raw JSON

bundles / traitlets latest / traitlets / traitlets / Tuple / __init__

function

traitlets.traitlets:Tuple.__init__

source: /traitlets/traitlets.py :3734

Signature

def   __init__ ( self * traits : t.Any ** kwargs : t.Any )  →  None

Summary

Create a tuple from a list, set, or tuple.

Extended Summary

Create a fixed-type tuple with Traits:

t = Tuple(Int(), Str(), CStr())

would be length 3, with Int,Str,CStr for each element.

If only one arg is given and it is not a Trait, it is taken as default_value:

t = Tuple((1, 2, 3))

Otherwise, default_value must be specified by keyword.

Parameters

*traits : TraitTypes [ optional ]

the types for restricting the contents of the Tuple. If unspecified, types are not checked. If specified, then each positional argument corresponds to an element of the tuple. Tuples defined with traits are of fixed length.

default_value : SequenceType [ optional ]

The default value for the Tuple. Must be list/tuple/set, and will be cast to a tuple. If traits are specified, default_value must conform to the shape and type they specify.

**kwargs

Other kwargs passed to Container

Aliases

  • traitlets.Tuple.__init__