{ } Raw JSON

bundles / traitlets latest / traitlets / traitlets / List / __init__

function

traitlets.traitlets:List.__init__

source: /traitlets/traitlets.py:3620

Signature

def __init__(self, trait: list[T] | tuple[T] | set[T] | Sentinel | TraitType[T, t.Any] | None = None, default_value: list[T] | tuple[T] | set[T] | Sentinel | None = traitlets.Undefined, minlen: int = 0, maxlen: int = 9223372036854775807, **kwargs: t.Any) → None

Summary

Create a List trait type from a list, set, or tuple.

Extended Summary

The default value is created by doing list(default_value), which creates a copy of the default_value.

trait can be specified, which restricts the type of elements in the container to that TraitType.

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

c = List([1, 2, 3])

Parameters

trait : TraitType [ optional ]

the type for restricting the contents of the Container. If unspecified, types are not checked.

default_value : SequenceType [ optional ]

The default value for the Trait. Must be list/tuple/set, and will be cast to the container type.

minlen : Int [ default 0 ]

The minimum length of the input list

maxlen : Int [ default sys.maxsize ]

The maximum length of the input list

Aliases

  • traitlets.List.__init__